grep search expression
Learn / Forums / General InDesign Topics / grep search expression
Tagged: GREP
- This topic has 5 replies, 4 voices, and was last updated 10 years, 1 month ago by Anonymous.
-
AuthorPosts
-
-
February 27, 2014 at 2:59 pm #67371TerrenceMember
HI all
Anyone out there know the quick GREP search terms for finding an apostrophe followed by a space then an uppercase letter?
-
February 27, 2014 at 3:33 pm #67375TerrenceMember
By jiggitty, give it up to the GREP newbie. I think I figured it out:
‘\s\u
This came in handy: https://creativepro.com/grep-and-text-metacharacter-cheat-sheet.php
.’\s\u apparently searches for any punctuation followed by an apostrophe followed by a space then an uppercase letter. It is finding instances where this happens between paragraphs, but I don’t mind.
-
March 4, 2014 at 10:25 am #67446Milt KlingensmithMember
Hi All,
I’m trying to write a grep to convert improperly styled times on a calendar to the proper style.
I want the grep to find “am.” and change it to “a.m.”
But since there is the possibility of having an “am.” being part of a show title such as “Sam I am.” I wanted to use a look behind to exclude an “am.” that is preceded by an “I” and a blank space.The negative lookbehind grep I was writing looks like this:
\s(am\.)(?<!I\s)I also tried a positive lookbehind for an am. preceded by a space and a digit to narrow the types of am.s that could be selected
\s(am\.)(?<=\d)The first one still selects the “am.” following the “I” and the space.
The second selects nothing.
Any ideas on how to use a lookbehind to select only the “am.” following a digit and a space?-
March 9, 2014 at 5:14 pm #67516Steve JenksMember
Hi Milt
I think it could be as simple as ignoring the look behinds and simply searching for any occurrence of a digit followed by a space followed by ‘am.’
If this is the case then if you searched
(\d )(am.)and replaced with
$1a.m.It should change just the times and leave the rest alone.
Steve
-
-
March 10, 2014 at 7:01 am #67520Milt KlingensmithMember
Thanks for the reply, Steve.
This is what I ended up writing that worked:
(?<=\d)am\.|(?<=\d/s)am\.|(?<=\d)am(?=\,)|(?<=\d/s)am(?=\,)|(?<=\d)am(?=\-)|(?<=\d/s)am(?=\-)|(?<=\d)am(?= *)|(?<=\d\s)am(?= *)|(?<=\d)am(?=\;)|(?<=\d\s)am(?=\;)
then replace with “a.m.”
It picks up every variation of the incorrect “am”s
-
March 10, 2014 at 1:42 pm #67536AnonymousInactive
Glad you got it sorted Milt.
-
-
-
AuthorPosts
- You must be logged in to reply to this topic.