Jump to content


Photo

preg_match vs eregi


  • Please log in to reply
3 replies to this topic

#1 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 10 July 2006 - 10:42 PM

I just was learning preg_match from the manual and i see that theres littile changes to eregi so what can preg_match do what eregi can not.



<?
$match="my little home";

if(preg_match("/little/",$match)) {

echo "matched";

}else{

echo " no match";

}


?>

<?
$match="my little home";

if(eregi("little",$match)) {

echo "matched";

}else{

echo " no match";

}


?>
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#2 ShogunWarrior

ShogunWarrior
  • Members
  • PipPipPip
  • Advanced Member
  • 528 posts
  • LocationIreland

Posted 10 July 2006 - 10:48 PM

Preg match uses PERL regex syntax, I believe it's just a bit expanded.

<a href="http://www.daviddora...nmedia.com/">My New Site/Blog</a> | <a href="http://www.daviddora...m/check/">Check your page for broken links/images/scripts</a>

Zend Certified Engineer
Follow me on Twitter: http://twitter.com/davidd

#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 10 July 2006 - 10:55 PM

ok i know see the diffrence i used this link to compare the diffrence in exspression code.

http://www.zend.com/...tern.syntax.php

but i still like eregi theo lol................
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#4 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 11 July 2006 - 02:20 AM

PCRE:
  • are (typically) faster;
  • are binary safe;
  • allow greediness modifications;
  • have better shortcuts (in my opinion);
  • are more advanced (lookarounds, recursion, subpatterns);
  • are decimal, octal, hex, UTF-8, and Unicode friendly;
  • have more switches, especially a documentation-friendly one (x).

Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users