Members Only

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.

Bookmark
Please login to bookmark Close

Not a member yet?

Get unlimited access to articles and member-only resources with a CreativePro membership.

Become a Member

Comments (5)

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. Dhafir Photo

    No need to use wS+ because S includes w

  2. Rocky Berlier

    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.

    1. Mike Rankin

      Looks like the site ate some of Bart’s code, specifically backslashes. Fixed now. Try it again and sorry for the hassle.

  3. Jill Orr

    Did not work for me.

  4. Dhafir Photo

    To avoid anything outside the address you can use
    and this is will better: