Connecting Tech Pros Worldwide Help | Site Map

ereg & preg_match

pomho
Guest
 
Posts: n/a
#1: Jul 17 '05
Hi all,

Even having read the PHP Manual, I can't understand the difference between
the ereg function and the preg_match...

Could anyone help ?

thx in advance,

--
pomho


Andy Hassall
Guest
 
Posts: n/a
#2: Jul 17 '05

re: ereg & preg_match


On Sat, 20 Mar 2004 16:38:54 +0100, "pomho" <pomho@nospam.org> wrote:
[color=blue]
>Even having read the PHP Manual, I can't understand the difference between
>the ereg function and the preg_match...[/color]

ereg uses POSIX extended regular expressions - these are defined by a standard
Unix specification, but have some limitations in what they can do.

preg_match uses PCRE (Perl Compatible Regular Expressions), which use the more
powerful and typically faster Perl-style expressions; the basics are the same,
but there's more pattern match expressions available in PCRE which means you
can match more complex expressions that would be awkward or just not possible
with ereg.

Unless you have a good reason otherwise, preg_match is preferred.

--
Andy Hassall <andy@andyh.co.uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
pomho
Guest
 
Posts: n/a
#3: Jul 17 '05

re: ereg & preg_match


> ereg uses POSIX extended regular expressions - these are defined by a
standard[color=blue]
> Unix specification, but have some limitations in what they can do.
>
> preg_match uses PCRE (Perl Compatible Regular Expressions), which use the[/color]
more[color=blue]
> powerful and typically faster Perl-style expressions; the basics are the[/color]
same,[color=blue]
> but there's more pattern match expressions available in PCRE which means[/color]
you[color=blue]
> can match more complex expressions that would be awkward or just not[/color]
possible[color=blue]
> with ereg.
>
> Unless you have a good reason otherwise, preg_match is preferred.
>
> --
> Andy Hassall <andy@andyh.co.uk> / Space: disk usage analysis tool
> http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space[/color]

Thanks you for your quick answer !

--
pomho


Closed Thread


Similar PHP bytes