RE: [PHP] simple regexp question - validating new line chars

From: Date: Sat, 08 Dec 2001 17:29:33 +0000
Subject: RE: [PHP] simple regexp question - validating new line chars
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-77122@lists.php.net to get a copy of this message
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:zenderx@ipro.pl] Sent: Saturday, December 08, 2001 12:10 PM To: php-general@lists.php.net 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: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#77122) next »