By Volume4
via immike.net
Published: Jul 20 2007 / 09:02
I’m going to assume you have a basic understanding of regular expressions at this point. If you’re a regex n00b (or /n0{2}b/, as I like to call them), or if you need a quick refresher, check out my previous post on the absolute bare minimum that every programmer should know about regular expressions. You won’t be disappointed.
So, without further adu, here are the five regular expressions that I have found the most useful for day-to-day web programming tasks.
Comments
kdavies replied ago:
This was a nice article, unfortunately it gave some bad information. For example, it suggested /^[a-zA-Z0-9_]{3,16}$/ to match a user name. That is way too complex when you can just use /^\w{3,16}$/ to match the exact same thing. Also the suggestion to use regular expressions for xml should be heavily qualified to point out there are a lot of times regular expressions just won't work for parsing xml. For example, he suggests {]*>(.*?)} to find the contents of a tag. This will work fine if you never have the same tag embedded within itself, but if you are doing webscraping like he suggests, you will often have things like " <div>This is a div <div>This is an embedded div</div><div>This is another embeded div</div></div>". In this case his regular expressions will match " This is a div This is an embedded div" and not what was intended.
Voters For This Link (20)
Voters Against This Link (3)