regex - Match not having .php using regular expressions -
with regular expressions, how match not having:
.php exactly? tried:
^[^\.php]+$ but seems match not . or p or h or p.
use negative lookahead in regex check whether there .php available or not.
$text = 'some php text'; if(preg_match("/^(?!.*\.php)(.*)$/", $text, $m)){ print_r($m[1]); } ^ beginning of string.
(?!.*\.php) checking if there no .php in upfront.
and (.*)$ capturing till end.
Comments
Post a Comment