GREP of the Month: Email Addresses
Learn how to automatically format email addresses when applying a paragraph style.

This article appears in Issue 70 of InDesign Magazine.
How to automatically format email addresses when applying a paragraph style.
InDesign helps you format email addresses when you use the Convert URLs to Hyperlinks command (in the Hyperlinks panel menu). But you have to run this command manually and repeat the process every time you’re handed new text. Instead, why not automate this process using GREP styles?
Knowing what you’re looking for
When you look at the structure of an email address, you’ll see that there are a lot of formations. Here are just a few examples: ba***************@******gn.com ba**********@*******om.au
You might think you need to look for any upper- or lowercase character, digit…or another special character…followed by the “@” symbol…followed by another series of characters…followed by a period…followed by “a few” other characters…Notice how hard this is getting? Let’s change strategies.
Knowing what you’re NOT looking for
One character you know cannot be part of an email address is the regular space character: , in GREP-speak. But instead of looking for
, look for
\S
, because using uppercase tells InDesign to look for everything EXCEPT that character.
Creating your GREP style
Start by editing your paragraph style. Add a new GREP style, and then, for the expression, type \w\S+@\S+\w
\w
looks for a “word character,” which is either an uppercase character, a lowercase character, or a digit. This helps avoid issues where an email address is next to a comma, parenthesis, or other characters that can’t be part of the address.
\S+
looks for a series of characters that does not include a space character.
@
looks for the actual @ character.
Commenting is easier and faster when you're logged in!
Leave a Reply
Recommended for you

Illustrator Downloadable: Tropical Shadow Overlay Kit
This downloadable package comes with two Illustrator files containing 14 symbols...

Illustrator Downloadable: Summer Citrus Pattern Set
Downloadables are an exclusive benefit for CreativePro members! (Not a member ye...

InDesign Downloadable: Tables SuperGuide
Downloadables are an exclusive benefit for CreativePro members! (Not a member ye...
No need to use wS+ because S includes w
Didn’t work for me either. Instead I used:
.+@.+..+
and it worked perfectly for email addresses with letters, punctuation, and numbers before or after the “@” sign. Neither my GREP Find nor the GREP styles dialog recognized the “S” or “s” characters as anything.
Looks like the site ate some of Bart’s code, specifically backslashes. Fixed now. Try it again and sorry for the hassle.
Did not work for me.
To avoid anything outside the address you can use
and this is will better: