that's because you're testing to see if '\n' is "\n"...single quotes mean: interpret the text between literally, so '\n' is a backslash followed by n...doulbe quotes mean: interpolate the value, so \n becomes a newline...
-----Original Message----- From: Krzysztof Jarecki [mailto:[EMAIL PROTECTED]] Sent: Saturday, December 08, 2001 12:10 PM To: [EMAIL PROTECTED] Subject: [PHP] simple regexp question - validating new line chars Hi everyone:) I need to validate a string that comes from a submitted form. There's nothing unusual in it... but the problem part showes up, when I need to validate a new line character... I have tried many diffrent variations of the code and I have ended up on something VERY simple: <?php $regexp='\n'; $text="\n"; echo $text; if (true==eregi($regexp, $text)) { echo 'ok'; } else { echo 'error'; } ?> Unfortunately this script results with "error" ;( Does somebody know how to make this regexp to work? Maybe it is a bug? I am using php 4.0.6 on windows 2000. I will appreciate any feedback about this ;) Chris Jarecki -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]