Help me with GREP
Learn / Forums / InDesign User Groups / Help me with GREP
- This topic has 11 replies, 5 voices, and was last updated 7 years, 3 months ago by James Nimmo.
-
AuthorPosts
-
-
April 1, 2016 at 11:32 am #83652Gregory CullenMember
Hi Im trying to figure out how to locate an exact set of letters and stylize just that grouping.
I need to find LLNYC wherever it appears and apply my Italic Character style that Ive set up.
BUT I dont want it to apply that style when LLNYC.com appears
JUST when it appears on its own.
Thanks
G -
April 1, 2016 at 1:29 pm #83656Ari SingerMember
Very simple, done with a negative lookahead.
LLNYC(?!.com)
Please keep me updated.
-
April 1, 2016 at 2:59 pm #83659Gregory CullenMember
ahh the wonder of help via the interweb! lol thank u so much Ari
i literally was struggling half the day trying to figure this one out
Works Perfectly
G
-
April 1, 2016 at 3:37 pm #83660Ari SingerMember
My pleasure!
You probably could’ve done it simpler as well. As I believe that LLNYC is a name that is always by itself with spaces on both sides (except in a URL of course, where it’s followed by .com), then you can just write this:
LLNYC
(notice the space after the C). So whenever it encounters something else than a space following the C it won’t pick it up. -
July 15, 2016 at 6:19 am #86537David PrescottMember
unless it just happened to come at the end of a sentence …LLNYC. Or if it was in the possessive: “LLNYC’s president said…” in which case Ari’s GREP solution would be the best :)
-
December 27, 2016 at 5:24 am #90768James NimmoMember
Can somebody please help me with a bit of GREP I cannot figure out?
I am a complete novice so please be patient with me.
I am putting together a programme for 2017 for my local sailing club. Within the programme are various events. For example, I would like all the training events to be coloured green. All the courses start with “RYA” and end in either a return or a tab.
For example on March 12th (Sunday and 12 are black. I want the rest green)
Sunday{tab} 12{tab} RYA Short Range Certificate (VHF) Exam{tab} RYA Powerboat Level 2 Course{end of para}My nearest thing to success has been the first 2 words appearing in green using “RYA \w*”
I would also like every social event which contains “Lunch or Dinner or Supper…etc” to be red. Again up to either a tab or end of para.
I have managed to get all events which containing “Committee Meeting (time)” to be grey using “\w+ Committee Meeting \(.+?\)” but that is my only success.
Can anyone please help me?
-
December 27, 2016 at 7:10 am #90772David BlatnerKeymaster
Looks like you need to learn about wildcards! :-)
RYA.+?\t
means “RYA followed by a string of any characters up to a tab.”
-
-
December 27, 2016 at 7:51 am #90774James NimmoMember
Yes, I do indeed need to learn a great deal about GREPs in general. Can you recommend any good books or websites?
Thank you so much David.
Any hints on the social events which contain “Lunch or Dinner or Supper…etc”?
They might have something before Dinner etc like “Dinghy Class Dinner” and/or after like “London” or “(Joe’s Café)”Many thanks again.
-
December 27, 2016 at 8:01 am #90775David BlatnerKeymaster
We have many articles and more about GREP here: https://creativepro.com/grep
If you search for GREP on our site, you’ll find even more. :-)
You’ll want to look for things like “positive lookahead” and “positive lookbehind”
-
-
December 27, 2016 at 11:43 am #90786James NimmoMember
Thanks David.
I am struggling.
Amongst the things I have tried is
(?<=)Lunch|Dinner|Supper|Drinks|Party(?=)You won’t be surprised that my efforts don’t work – I have clearly misunderstood the instructions.
Any suggestions?
-
December 27, 2016 at 1:08 pm #90787David BlatnerKeymaster
A different thought: if each of these lines is set up in a similar way (with tabs separating each section), then you should consider one of two different options, which don’t involve GREP:
- You could just select the paragraphs and convert them into a table. The rule is: If you’re making something that looks kind of like a table, and smells like a table, then it probably should be a table! :-)
- You could use nested styles… just make character styles, and then apply them using nested styles rules to each section using the “up to” tab rule. Here’s a silly example of nested styles, but it gives the basic idea: https://creativepro.com/holiday-text-fx-part-3-fun-with-nested-styles.php
-
December 27, 2016 at 3:10 pm #90788James NimmoMember
Many thanks David.
-
-
AuthorPosts
- You must be logged in to reply to this topic.