I am using the following regex to check for valid email
addresses, but I am getting errors.
Expand|Select|Wrap|Line Numbers
- if (preg_match('\^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$\',$regex)){
- echo "VALID";
- }
- else {
- echo "INVALID";
- }
Warning: Unexpected character in input: ''' (ASCII=39) state=1 in /home/guru54gt5/public_html/im/regex.php on line 6
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/guru54gt5/public_html/im/regex.php on line 6
Parse error: syntax error, unexpected '^', expecting ')' in /home/guru54gt5/public_html/im/regex.php on line 6
Line 6 refers to the if stmt line in my script.
I took the example from a tutorial and I thought that I understood everything, but I can not
see why this is causing errors :)
PS I changed the single quotes to double:
if (preg_match("\^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$\",$regex)){
and now I get just one error:
Parse error: syntax error, unexpected T_STRING in /home/guru54gt5/public_html/im/regex.php on line 7
But, again, I do not see why
Thanks for any help.