Sizzling Safari Tips for Mac Users ebook.  22 Tempting Timesavers for Mac Users ebook.

Search here or browse MacTips by topic.

Matching Joe Cool 2

Eudora Tip #199/01-Oct-2003 Matching Joe Cool 2 Bob Williams continues his Tip for using Regular Expressions. The next few Tips will bring the remaining Examples. Example 2 Let’s make Joe Cool’s situation a little more complex. Say that, in addition to the two addresses mentioned in Part One, he sometimes sends out mail from <joe_c@example.edu> [...]

 

Eudora Tip #199/01-Oct-2003
Matching Joe Cool 2

Bob Williams continues his Tip for using Regular Expressions. The next few Tips will bring the remaining Examples.

Example 2

Let’s make Joe Cool’s situation a little more complex. Say that, in addition to the two addresses mentioned in Part One, he sometimes sends out mail from <joe_c@example.edu> and <joe@bigserver.eng.example.edu>. How do you set up a filter to catch Joe’s messages? You could simply have it look for “example.edu” in the return address, but what if you know other people at the school who send you e-mail? In that case, your next move might be to set up a couple of filters, or maybe a single filter with multiple match criteria. However, with a single regular expression, we can cover all of Joe’s possible addresses. To put this together, let’s break it into steps, which is a good way to construct regular expressions until you get the hang of them (and then, still a good way when putting together complex expressions):

An expression to match “joe_c@” or “joe@”: joe(_c)*@

This is directly taken from Example 1, so you already know how it works.

An expression to match “cs.example.edu” or “example.edu” or “bigserver.eng.example.edu”: [A-Za-z.]*edu

Here, square brackets are used to say “match a pattern that consists of any character in the range a-z, or in the range A-Z, or that’s a period”, the * says to repeat that pattern any number of times, and the edu part says the whole pattern has to conclude with ‘edu’. Thus, the pattern will match any series of letters and periods followed by ‘edu’.

Combine the above two for our final regular expression: joe(_c)*@[A-Za-z.]*edu

Robert E. Williams, Jr.

President, TriVectus, LC www.trivectus.com

Visit our site to learn about our web consulting services, and to download our freeware and shareware software and desktop pictures. Also, be sure to sign up for our new newsletter, Overture, which will help you increase your site’s ROI.

If you’ve found this Part Two useful please visit Bob’s website and be sure to read Part Three next week.

If you found this Tip useful you definitely need my ebooks Sizzling Safari Tips for Mac Users & 22 Tempting Timesavers for Mac Users. And remember to subscribe for regular Tips.

Tell us what you think.
Note: your comment is not published straight away. I check and approve all comments, otherwise the spammers get a free rein. I usually check comments within 24 hours.

Add your Comment

Take Control ebooks (affiliate link) are superb.
I do some of my best learning from them. Buy through my link so I can make more and better Tips.

Take Control of Using Lion.   Buy Take Control of iCloud.  Take Control of BBEdit.