Alex Rivera | Logout

What are some of the most useful regular expressions for programmers?

Asked 2009-09-19T23:44:33.943
23

I am new to regular expressions and have just started learning some. I was wondering what are some of the most commonly used regular expressions by the programmers. Put it in another way, I would like to know what are the regular expressions most useful for? How can they help me in my every day tasks? I would prefer to know regular expressions useful for every day programming, not occasionally used regular expressions such email address matching.

Anyone? Thanks.

Edit: Most of the answers include regular expressions to match email addresses, URLs, dates, phone numbers etc. Please note that not all programmers have to worry about these things in their every day tasks. I would like to know some more generic uses of regular expressions, if there are any, which programmers in general (may) use regardless what language are domain they are working in.

Edit
Report

1 Answer

2

This is a little like asking 'what are the most useful words for programmers?'

It depends what you're going to use them for, and it depends which language. And you didn't say.

Some programmers never need to worry about matching email addresses, phone numbers, ZIP codes and IP addresses.

My copy of

Mastering Regular Expressions, O'Reilly, 3rd Edition, 2006

devotes a lot of space to the flavours of regex used by different languages.

It's a great reference, but I found the 2nd edition more readable.

answered 2009-09-19T23:56:55.247

Your Answer