I'm brand new to GREP and its uses in InDesign, and while I'd like to understand it in a more robust way someday, at the moment I'm struggling to find some resources that can explain just the basics to me in a comprehensible way.

So, Question #1: If you happen to know of such resources, it would be awesome if you could point me toward some. Keep in mind I am a designer not a coder, so if the resource is riddled with coding jargon like "shell" and "escapes" and "environment variables in the regex" I am not going to have any idea what those words mean. I can generally grasp coding principles pretty well but I don't know the vocab.

Question #2: Can someone tell me how to write a GREP expression that will target any grouping of characters containing a period with letters and/or numbers on either side of it, but no space? I am looking to target URLs, email addresses, and phone numbers, and our house style writes those as the following:


[email protected]


What I want to do is make it so that line breaks never happen in the middle of these "words." I know it involves creating a character style with the No Break setting and then using a paragraph style to apply the character style using GREP, but I don't know how to write these parameters in GREP. Targeting anything between spaces that has a period should work but I don't know how to write that.

Question #3: Can we write a second expression targeting social handles and hashtags? So that would be any word starting with a @ or # that may or may not have numbers and/or an underscore in it. If it is followed by any punctuation before the next space aside from an underscore, I would like the punctuation to not be included in the expression. (So , . ! ? — - should not be included in the expression but _ should.) This should probably distinguish social handles from email addresses by specifying that a social handle will always have a space before the @ (whereas an email address would not), but I would prefer the preceding space to not be part of the selection.

Bonus!: I would love, love, love it if these answers could come with explanations for why they work and what they're doing. I'll still love answers that solve my problem and teach me nothing in the process but that's only 1/3 of my available love. Teach a man to fish and all that. :)

3 Answers 3


The best resource I know for beginning to understand how to use GREP in InDesign is the InDesign Secrets website. They have an entire resources section about using GREP, and I believe there are articles linked there that specifically address writing GREP for all three of the situations you address in your Question 2. And I know they have at least one article all about setting certain types of text as "no-break."

You can find this information here: https://indesignsecrets.com/resources/grep

There is quite a bit of explanation as to why certain GREP works the way it does in the various articles listed here, but I also struggle with this issue. So another great resource that helps me is http://regexr.com/. It is a sight specifically designed to help you learn to use GREP--you can write GREP codes and get immediate feedback about what they are doing, and there is a tab called "Explain" that actually tells you what each section of your expression actually means.

I still struggle with using GREP, but these two resources have been really helpful in allowing me to develop better skills.


GREP Find/Change and GREP Styles will change your life. :) I was in the same boat as you about 2 years ago. magerber gave the same resources that I would have suggested. I went ahead and wrote the expressions that you are looking for.

I find URLs to be little difficult because they are less predictable. I often have to tailor my expression to the document that I am working in. If your urls truly are as simple as you say then this should get you started but it will likely need some fine tuning.



Same story with emails.

[email protected]





If you have an email address like some of ours in the UK it will look like

[email protected]

And the GREP expression above won't pick up the .uk

So I use:


This seems to work with both .co.uk (and e.g. .ac.uk) as well as .com

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.