#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2010
    Posts
    1
    Rep Power
    0

    Information about regex please


    I'm doing an essay on regular expressions used in PHP but I can't find anything that acts as an overview.

    I want to know:-

    1. Do regex only run if you have a specific program installed? I am reading a book on them and it mentions Egrep and that you need to install egrep to use it. Do you have to install lots of programs to use specific regexs then?

    2. How many different regex languages are there? Is it only POSIX and Perl-compatible? I know those are the only two supported in PHP, but are they more?

    Think thats all so far!

    Thank you in advance.
  2. #2
  3. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6351
    1) No, PHP has multiple built-in regular expression parsers.

    2) There are various "flavors" of regular expressions, some languages have complete perl-compatible support, and some of them trail off. PHP, in particular, can't do a lookaround for a string longer than one character, while perl can. The ASP/.NET regular expression engine also has a fault that I can't remember right now. You can pretty much consider them all the same for basic things, it's only once you become an expert that you need to worry about compatibility between languages.

    The wiki article is bound to know more than us.

    -Dan
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2010
    Location
    Norcross, GA
    Posts
    8
    Rep Power
    0
    Most programming languages have regex capabilities built in, and yes, there are different flavors of regex between different languages, though many of them will try to mimic the same syntax, and even for those that don't, the vast majority of regex elements are the same.

    Like ManiacDan said, it's not until you get knee-deep in regex that you really need to worry about the differences.

    For more info and comparisons between regex flavors, go to Wikipedia and search for "comparison of regular expression engines".

IMN logo majestic logo threadwatch logo seochat tools logo