I was wondering if any of you guys know of a good tutorial on regex. I'm able to do most of the simple stuff, but still confused by some of the more advanced pattern matching.

Recommended Answers

All 5 Replies

Do you know if there's a difference between perl-compatible regex and php-compatible regex (which is what I use)?

PHP's ereg regexes use the POSIX Extended regex features, which are described decently at http://en.wikipedia.org/wiki/Regular_expression These pretty much form a subset of Perl-compatible regex features -- Perl-compatible regexes support lazy matching, like (foo)*? , and have more codes for convenient things like digits with \d and word boundaries with \b and such. According to the PHP manual, the POSIX Extended regex library, when used with PHP strings, aren't binary safe and will not match past a nul character placed in the string, and the perl-compatible version (available in PHP with functions whose names begin with "pcre_") has a faster implementation anyway.

I'm incredibly confused by what you just said but I'll take your word for it that if I read all of these tutorials that, by the end, I'll have a much clearer understanding :)

Thanky :)

Cheers

> I'm incredibly confused by what you just said but I'll take your word for it that if I read all of
> these tutorials that, by the end, I'll have a much clearer understanding

You shouldn't be; the basics as well the pretty advanced stuff remains more or less the same. My recommendation would be the book 'Mastering Regular Expressions' which is a must read for all those who want to be regex gurus.

Though the basics are the same, the application of regular expressions depends a lot on the language you use, so unless you consult your language documentation, you might be in for a big surprise. :-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.