ereg & preg_match

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • pomho

    ereg & preg_match

    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

    #2
    Re: ereg & preg_match

    On Sat, 20 Mar 2004 16:38:54 +0100, "pomho" <pomho@nospam.o rg> 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

    Comment

    • pomho

      #3
      Re: ereg &amp; 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


      Comment

      Working...