-
1. Re: CS5 - Grep style problems
pkahrel Apr 19, 2011 1:38 AM (in response to Tom Usrey)You can't do all this in one GREP style. The one you came up with is already difficult to read, so you can imagine what happens to its readability by the time you get it to work. Apart from that I don't think it's possible to do what you want in one expression.
So you really need to split up your task into several chunks, all of which you can then add to the same paragraph style. Your expressions may be more efficient, but they're much eaier to understand and maintain. Here goes.
The easy ones are AAA, B23, and (ABC-1), all of which are captured by this expression:
\(?\u[-\u\d]+\)?
U.S.A. is more tricky, and it needs to be split in two itself. The first part captures series capital+period, but not the last one:
\u(?=\.\u)
Capturing the last capital+period is interesting in that it requires a negative lookahead embedded in a positive lookahead, which I wouldn't have thought was possible, but it works:
(?<=\.)\u(?=\.(?!\u))
For the numbers you's do something similar.
Peter
-
2. Re: CS5 - Grep style problems
Tom Usrey Apr 20, 2011 2:59 PM (in response to pkahrel)Peter,
Thanks for your input. I realize your suggestion about splitting it up is the way to go. And your handling of the "U.S.A." sample is right on.
But I see that I need to do some more playing around to see if I'm going to be able to get this to work. For example, your expression to catch one of the "easy ones" -- (ABC-1) -- also catches all the punctuation, and I didn't want to catch any of the punctuation. And in the sample "4,444,444" mine was catching the first punctuation, but yours instead isn't catching the first character. So I'm going to continue working on this and will come back later if I get something that works.
Hopefully your help has put me on the right track.
Tom
-
3. Re: CS5 - Grep style problems
Marc Autret Apr 20, 2011 4:44 PM (in response to Tom Usrey)Hi Tom,
Just a stupid question. What is the issue in using a rule like:
[\u\d](?![\l'])
?
@+
Marc
-
4. Re: CS5 - Grep style problems
pkahrel Apr 21, 2011 4:03 AM (in response to Tom Usrey)> I didn't want to catch any of the punctuation
Then just leave out the punctuation: \u[-\u\d]+
The numbers can probably be captured by this one:
\d?\d?\d(,\d\d\d)+
i.e.batches of comma+three digits preceded by at least one but up to three digits.That's the pattern that your examples suggest.
Peter
-
5. Re: CS5 - Grep style problems
Tom Usrey Apr 21, 2011 3:18 PM (in response to Marc Autret)Marc,
Yours also catches the single caps or digits that stand by themselves.
For example, in the sentence -- A train of 3 cars -- we don't watch to catch the "A" or the "3".
Other than that, yours seems to work the way we wanted.
-
6. Re: CS5 - Grep style problems
Tom Usrey Apr 22, 2011 11:42 AM (in response to Tom Usrey)Peter and Marc,
Thanks to both of you for your insight on my problem. I've taken a little of both of your answers and think I'll be able to work them into a solution for our needs.
I've awarded each of you a "Helpful Answer".
And Peter, just wanted to let you know that your O'Reilly GREP digital book has been a great help me in beginning to learn GREP.
Tom



