regex - PHP Preg_match: attempt to match a string where a substring does not exist in the string -


I'm trying to get this regex work Assume that to get the parsed URL, if the string '_skipThis' is found, then the string does not match. In addition, backtraarfons are also required for example:

  string 1: a_particular_part_of_string / a / b / c / d / e / f Result: Preg_match should return actual backfinance: $ 1 - & Gt; A_particular_part_of_string, $ 2 - & gt; / A / b / c / d / e / f string 2: a_particular_part_of_string_skip this / a / b / c / d / e / f Result: preg_match should return incorrectly. Backfirst: Nothing here.  

I have tried the following regex.

  reg1 = ([a-zA-Z0-9_] +) (\ /.* ) Reg2 = ([A- zA-Z0- 9] + (?! SkipThis)) (\ /.*) reg3 = ((?! _ Skip this).) (\ /.*) reg4 = (( ?! _ Skip this [[A-zA-Z0-9 _] +) (\ /.*)  

Please help me! thank you in advanced!

Just match _skipThis and false if it is found.

  if (strings ($ string, '_pip this') === false) {// display preg_match} and then false return;  

(Of course this is a regex for. Suppose that _skipThis appears only before the first / ,

  return preg_match ('^ ^ ([^ /] +) (? & Lt;! _ SkipThis) (/.*) $ |', $ theString); // ------ - ----- $ 1 -------------- $ 2 // Make sure it is * not * first '_skipThis'  

Otherwise, if

  return preg_match ('| ^ (?!. * _ SkipThis) ([^ /] +) (/.*) $ |', $ TheString) , // --------------- // Make sure '_skipThis' is not found anywhere.  

Comments