Copy link to clipboard
Copied
I d-i-d give this the old college try, but maybe I dont know the right place or I'm limited by Nested Style or by GREP style.
I have any number of predictably unpredictable characters that I want to apply a CH style "up to"
Example 1: The InDesign Club of the Future Meeting, 3:30 pm: Here is some sample text .... Here is some sample text .... Here is some sample text .... — in this case, "up to" colon
Example 2: The InDesign Club of the Future Meeting, 3:30 pm - Here is some sample text .... Here is some sample text .... Here is some sample text .... — in this case, "up to" space hyphen space
Example 3: The InDesign Club of the Future Meeting, 3:30 pm -- Here is some sample text .... Here is some sample text .... Here is some sample text .... — in this case, "up to" space hyphen hyphen space
Example 4: The InDesign Club of the Future Meeting, 3:30 pm, Here is some sample text .... Here is some sample text .... Here is some sample text .... — in this case, "up to" any character (comma) [of course, there's an argument in this one]
There are 5-6 predictable samples. But Nested Styles stacked on top of each other tends to bold the whole paragraph. Would a js script be more applicable here or do you see GREP style working? I have failed (even with my books on GREP) to nail any type of pattern down.
How will you tell the difference between the first and the second comma in Meeting, 3:30 pm,? They're both followed by a space. Can pm be the clue? Then ^.+?pm\s[:,-]-? might work.
Peter
Copy link to clipboard
Copied
use a GREP style instead of a nested style.
something like this ^.+?[:-–] etc
Copy link to clipboard
Copied
Tried it, but no luck. Thank you Vamitul.
Copy link to clipboard
Copied
you shure? how did you define the grepStyle? for me (win, id 5) it works perfect.
Copy link to clipboard
Copied
How will you tell the difference between the first and the second comma in Meeting, 3:30 pm,? They're both followed by a space. Can pm be the clue? Then ^.+?pm\s[:,-]-? might work.
Peter
Copy link to clipboard
Copied
Right on the nose, Peter. I need to go back to your book and read exactly the statement your GREP is making.
Copy link to clipboard
Copied
Peter, it's another thread for this.... but it's interesting that scripts work for hours one night, and then don't behave in the morning. Nothing changed except for the Mac that shut down and restarted. This is all new and it's confusing as where to begin to research it. Have seen it lately on all variations of the Find Change by List.
Copy link to clipboard
Copied
Do you see this only after using Find Change by List?
P.
Copy link to clipboard
Copied
It's exclusive to this script. I've had many chains break now. Quit ID, come back in. Reboot. I don't underdtand it.
Copy link to clipboard
Copied
Maybe start a new thread. People with experience with Find Change by List may not look at this thread here.
Peter
Copy link to clipboard
Copied
Peter Kahrel wrote:
How will you tell the difference between the first and the second comma in Meeting, 3:30 pm,? They're both followed by a space. Can pm be the clue? Then ^.+?pm\s[:,-]-? might work.
Peter
Hi Peter,
I am confused by your answer to the original question.
I MadMac 1st and 4th examples there is not a space after the pm so I can't understand how your GREP will work
Regards
Trevor
Copy link to clipboard
Copied
Trevor, my example was an attempt to point out that it was a moving — and redundant —target and what Peter did was look for a trend that got around the redundancy. The colon crops up in 2 places, one followed by no spaces and one followed by "any number of spaces." Peter's idea to use the "\s" allows for any number of spaces following a colon. Which means if the author makes a mistake, the GREP even accounts for that.
Copy link to clipboard
Copied
Trevor is right: the space following pm should be optional, as in ^.+?pm\s?[:,-]-?
Copy link to clipboard
Copied
Hi Peter
I see you beat me to it by 10 minutes but at least I put a nice add in for you
Copy link to clipboard
Copied
Thanks, Trev !
Peter's book is worth 5 times what we paid (wink-wink) and as a person he's worth a million times more. Thanks for the explanation. WHen I initially wrote the post, I tried to show more simply the kind of problem I was having. It was more extensive than that. But by opening the thread I was able to see how to go about making the discriminating choices of characters to change.
You've both been great, and I just love the explanation you did.
EDIT: I wish Peter would write a revision to his book and charge us all more. More along the lines of examples he's found with the kind of explanation and breakdown. The point-by-point explanation is so incredibly valuable to breaking down problems like it. I rack my brain in his book first, then come here when I can't get a grip. There, another ad for Peter!
Copy link to clipboard
Copied
Thanks for your kind words, both of you. I am in fact reworking the book (the JS title too). I was thinking of adding point-by-point explanations.
Peter
Copy link to clipboard
Copied
My own WhattheGrep fails on some edge cases (.. and somehow I always forget which ones they are ..), but it performs as expected on this one:
^.+?pm\s[:,-]-?
^ Start of Paragraph, Story, Footnote, or Cell
. Any single character
+? Matching any character may occur once or more times; shortest match will be taken
pm Literal text "pm"
\s Any white space
[ Inclusion: any character in this group
:,- Any of these characters
] End Inclusion Group
-? The character "-" may occur once, or not at all
^ . +?pm\s[:,-]-?
There is a Surprise Face hidden inside! :,-
Copy link to clipboard
Copied
Oooooh, that's a good one, Theunis, WhattheGrep !!! This will keep me from having my mouth washed out with soap on my next adventure.
Copy link to clipboard
Copied
Peter, that's great news. I'll want my copy personally signed of course!
Copy link to clipboard
Copied
Hi Mad,
Sorry to say but I think you're quite off there.
In examples 1 and 4 there are no spaces after both colons (Yes it is true that 0 is included in any number) but the \s in the grep is not followed by a * which would mean any number of (in this case spaces) from none to an unlimited amount. If the \s was followed by a ? then it would mean 0 or 1 space as it is just \s it means there has to be one and only one space after the pm.
Thus Peter's Grep ^.+?pm\s[:,-]-? means
Find
^ from the beggining of the paragraph
.+ at least one character / space
? up to pm (minuman find)
pm the leters pm
\s one and only one space type character
[:,-] followed by one and only one of the characters : or , or -
-? followed by an optional first or second -
In fact the correct Grep to get your 4 examples would be along the lines of
^.+?pm *[:, -]-? or more likely ^.+?pm[:, -]+
The latter Grep allows for have no spaces after the pm but allows also for numerous spaces dashes and not so great comas and colons (these could be dealt with but it's probably not necessary!
To be honest I think Peter must have been a bit on the sleepy side when he gave the answer I'm sure he will confirm this
Regards to all
Trevor