PHP Regex using the \Q \E syntax -
i reading on regex's , says: all characters between \q , \e interpreted literal characters. e.g. \q*\d+*\e matches literal text *\d+*.
so tested out:
$pattern = '/\q~!@#$%^&*()_+|}{?><,./\][":';\e/'; $string = '~!@#$%^&*()_+|}{?><,./\][":';'; preg_match( $pattern, $string, $matches ); echo "<pre>"; print_r($matches); echo "</pre>";
it gives me error:
parse error: syntax error, unexpected '~' in /applications/xampp/xamppfiles/htdocs/xampp/web_development/new_study_2014/regex.php on line 3
why not working stated above?
you forgot quote '
within patterns:
$pattern = '/\q~!@#$%^&*()_+|}{?><,./\][":';\e/'; ^--start string #1 ^--end string #1 ^--start string #2 $string = '~!@#$%^&*()_+|}{?><,./\][":';'; ^---end of string #2 ^---your error, because it's outside of string
php regex
No comments:
Post a Comment