1
我一直在試圖獲得這個正則表達式的工作。假設解析URL,如果找到字符串'_skipThis',則不匹配字符串。反向引用也是需要的。例如:PHP Preg_match:嘗試匹配字符串中不存在子串的字符串
String 1: a_particular_part_of_string/a/b/c/d/e/f
Result: preg_match should return true
Backreference: $1 -> a_particular_part_of_string, $2 -> /a/b/c/d/e/f
String 2: a_particular_part_of_string_skipThis/a/b/c/d/e/f
Result: preg_match should return false.
Backreference: nothing here.
我曾嘗試以下的正則表達式..
reg1 = ([a-zA-Z0-9_]+)(\/.*)
reg2 = ([a-zA-Z0-9]+(?!_skipThis))(\/.*)
reg3 = ((?!_skipThis).*)(\/.*)
reg4 = ((?!_skipThis)[a-zA-Z0-9_]+)(\/.*)
請幫幫我!提前致謝!!!
非常感謝你的幫助。 「a_particular_part_of_string」的含義是不一樣的。謝謝! – 2010-09-27 16:18:28