The Friday Fillip

\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b

Ever searched for one?

We’re used to searching the internet or databases for documents, making good use of Boolean search logic or its local variant I hope. But how good are we at searching within a document for a particular kind of text string or location?

What you see above is a series of “regular expressions” (or regexes) that will find you any email address within a text, at least if searched for with a “regular expression engine.”My own favourite is TextPad, an excellent text editor with a host of great features. Indeed, a great deal of the text processing that I do doesn’t require the jumbo weight of a word processor, so I’d use TextPad even if I never searched with regexes. There’s not a lot you can’t do with this powerful tool — find the first word that has an “a” in it after the 17th line of text; find all occurrences of the word “jones” that occur at the end of a line; find a word within so many words of another word; and so forth.

Regular expressions aren’t easy to learn, but if you like constructing precise searches, or if you have to search and replace terms in a document that are not straightforward, you may find yourself motivated to try.

If you do — find yourself motivated, that is — take a look at regular-expressions.info. There’s a decent tutorial there to get you started.

Comments

  1. Now you know how I built my RSS Feeds! :-) Without replacing curly quotes and apostrophes, I couldn’t get the XML to validate. Thank-you regex! Lots of great applications out there…