Search the Community
Showing results for tags 'preg_match'.
-
this is my code $re = '/[^\W][a-zA-Z\d.-]{3,20}/'; if(!preg_match_all($re, $username)){ do something }else{ do somthing else } $username is a $_POST['username']; when i submit a 3 letter word it works but when i use symbols like $ and ! and etc it still goes through, im trying to get a regex where the username is 4-20 characters long and only the alphabet and numbers and dots and dash but dots and dashs cant be next to each other thx
-
I am trying to use preg_match to check whether a membership number has been entered in the form 'A123456'. I have found a site on the web that shows the types of string syntax that can be used to check a string, so I have come up with the following: preg_match ('/P.P/ \d{6}', $trimmed['BMFA_No']) However when run I get the following error: An error occurred in script D:\wamp\www\MFC1066\Reg1.php on line 19: preg_match(): Unknown modifier '\' Obviously I have the syntax wrong, but as I have never used this command before I am unsure where this is wrong. I am sure that someone out there is much more experienced that me and can solve this easily.
