Reputation: 101
im not sure why this wont work... works perfectly in multiple regex
checkers and testers. but when it comes to running it in PHP
i get this error:
Warning: `preg_match()` [function.preg-match]:
Compilation failed: nothing to repeat at offset 6 in /home/splose/public_html/index/index.php on line 49
im running this:
if(preg_match('[\\/^$.|?*+():<>]', $username)){}
Upvotes: 3
Views: 22354
Reputation: 1
I think you should use regex expression with delimiters forward slashes (/)
// wrong pattern
$pattern = '[\\/^$.|?*+():<>]';
// right pattern
$pattern = '/[\\/^$.|?*+():<>]/';
if(preg_match($pattern, $username)){}
Upvotes: 0