Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compilation failed: nothing to repeat at offset 6

Tags:

php

preg-match

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)){}
like image 214
smeddles24 Avatar asked Feb 18 '26 15:02

smeddles24


1 Answers

Perhaps you can try to delimit your pattern?:

if(preg_match('/[\\/^$.|?*+():<>]/', $username)){}

Taken directly from the PHP Docs :

Often used delimiters are forward slashes (/), hash signs (#) and tildes (~).
like image 146
Nonym Avatar answered Feb 20 '26 04:02

Nonym



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!