RE: [PHP] Re: preg_match

From: Date: Fri, 20 Jun 2003 16:32:22 +0000
Subject: RE: [PHP] Re: preg_match
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-152319@lists.php.net to get a copy of this message
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Thanks, I weas reading on the php website under the preg_match functino and people were saying that you had to excape the $ so that iw ould be evaluated right. That's what got me confused. - --- Aaron Axelsen AIM: AAAK2 Email: axelseaa@amadmax.com Want reliable web hosting at affordable prices? www.modevia.com Web Dev/Design Community/Zine www.developercube.com - -----Original Message----- From: sven [mailto:svenie@gmx.li] Sent: Friday, June 20, 2003 4:31 AM To: php-general@lists.php.net Subject: [PHP] Re: preg_match preg_matchtry without backslashes. $pattern = "/$search/i"; if (preg_match ($pattern, $date[$i])) { echo "$date[$i]<br />"; } you don't need the .*? in your regex (either * or ? multiplier) as preg_match searches for any occurance (not from begin ^ or to end $). ciao SVEN "Aaron Axelsen" <axelseaa@amadmax.com> schrieb im Newsbeitrag news:000101c336ea$3efd9840$6400a8c0@DELTA... -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I am trying to code a search, and i need to get my matching expression to work right. The user can enter a value swhich is stored in the vraible $search. What the below loop needs to do, is search each entry of the array for any occurance of the $search string. If i hard code in the string it works, but not when passed as a varaible. Is there something I am missing? Do i need to convert the $search variable to soetmhing? if (preg_match ("/.*?\\\$search.*?/i",$date[$i])) { print "$date[$i]<br>"; } - --- Aaron Axelsen AIM: AAAK2 Email: axelseaa@amadmax.com Want reliable web hosting at affordable prices? www.modevia.com Web Dev/Design Community/Zine www.developercube.com -----BEGIN PGP SIGNATURE----- Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com> iQA/AwUBPvKWA7rnDjSLw9ADEQIfGQCgwAO5ikh/RIN5OXoVkC8F4FH/YAoAoJE5 zMxHkRssHbU2Vm4svv2hId8O =DJOi -----END PGP SIGNATURE----- -----BEGIN PGP SIGNATURE----- Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com> iQA/AwUBPvM3FrrnDjSLw9ADEQLSSQCgp9Fmuoyn1LEkAA2vhcAsbXdsoKMAnjXd VSnoMXvBNIzW4BmJdk7Ki8rt =aWuk -----END PGP SIGNATURE-----

« previous php.general (#152319) next »