: InDesign: Using GREP to style URLs, email addresses, phone numbers, social handles, and hashtags I'm brand new to GREP and its uses in InDesign, and while I'd like to understand it in a more
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:
url.com
emailaddress@email.com
000.000.0000
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. :)
More posts by @Gail6891361
2 Comments
Sorted by latest first Latest Oldest Best
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.
url.com
(w+.[lu]{3})
Same story with emails.
emailaddress@email.com
w+@(w+.[lu]{2,3})
000.000.0000
(d{3}.d{3}.d{4})
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: 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 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.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.