Page 1 of 1

problem with ereg and backslashes

Posted: Sun Oct 19, 2008 10:51 pm
by mottwsc
I'm allowing users to send an email as an invitation. I pre-fill it (using \n for new line), let them edit it and check if after that. I always get a negative response in the ereg when including \ in the string, and I can't figure out how to fix it. Any suggestions?

Code: Select all

 
$invitationClean = "Hello.\n\nYou are invited.";
if( !ereg("^([A-Za-z0-9',. -!\\]{0,250})+$", $invitationClean) )
{ echo "invitationClean - bad data<br>"; }
else
{ echo "invitationClean - OK data<br>"; }
 

Re: problem with ereg and backslashes

Posted: Sun Oct 19, 2008 11:47 pm
by novice4eva
Its not \ that's giving you the problem, i think it's with \n, so why don't you try

Code: Select all

 
if( !ereg("^([A-Za-z0-9',. -!\n\\]{0,250})+$", $invitationClean) )
 

Re: problem with ereg and backslashes

Posted: Mon Oct 20, 2008 12:13 pm
by mottwsc
Thanks, that helped with the \n problem.