Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 03-31-2004, 07:56 AM   #1 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,487
sde is on a distinguished road
ereg vs preg_match

which method do you use to match regular expressions in php? i don't understand the differences.
__________________
Mike
sde is offline   Reply With Quote
Old 03-31-2004, 02:43 PM   #2 (permalink)
bdl
Senior Contributor
 
Join Date: May 2002
Location: vta.ca.usa
Posts: 555
bdl is on a distinguished road
I use preg_match() mainly because I prefer working with the PCRE (Perl Compatible Regular Expressions) syntax vs. 'regular' syntax. It has been estimated that the preg_ PCRE functions have a performance edge over using ereg_ style functions.

http://us2.php.net/PCRE
http://us2.php.net/manual/en/pcre.pattern.syntax.php
bdl is offline   Reply With Quote
Old 03-31-2004, 04:01 PM   #3 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,487
sde is on a distinguished road
thanks b!
__________________
Mike
sde is offline   Reply With Quote
Old 03-31-2004, 04:31 PM   #4 (permalink)
bdl
Senior Contributor
 
Join Date: May 2002
Location: vta.ca.usa
Posts: 555
bdl is on a distinguished road
Sure. It occurred to me later that in alot of cases if you're matching something simple, ereg() or even strpos() are more than adequate to handle the match. OTOH, preg_match() does give you, alot more flexibility and power through the PCRE style expressions.
bdl is offline   Reply With Quote
Old 04-08-2004, 06:33 PM   #5 (permalink)
idx
Senior Grasshopper
 
idx's Avatar
 
Join Date: Jun 2003
Location: FL
Posts: 317
idx is on a distinguished road
I prefer preg_* merely for the perl-compatibility, but I'll certainly take any speed benefits that come along with it. Unless I'm doing some basic string matching, I'll pretty much stick with preg_ .

-r
idx is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 07:13 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting