-----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: [EMAIL PROTECTED]

Want reliable web hosting at affordable prices?
www.modevia.com
 
Web Dev/Design Community/Zine
www.developercube.com



- -----Original Message-----
From: sven [mailto:[EMAIL PROTECTED] 
Sent: Friday, June 20, 2003 4:31 AM
To: [EMAIL PROTECTED]
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" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
  -----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: [EMAIL PROTECTED]

  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-----



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to