Copy link to clipboard
Copied
Hello!
I use a lot of cross-refs which consist of a chapter number and some text, separated by a space and everything enclosed in quotation marks. Example: "1.1 This is an example"
I made a GREP to find them: (")(\d+.+?) (.+?)(")
For some reason, using the placeholders for left and right double quotation marks doesn't work in my document, but in another, so I used the "any" placeholder. So far, this GREP finds all cross-refs.
However, it's supposed to stop at the end, at the right double quotation mark that encloses the cross-ref.
Some of the headlines the cross-refs are made from also contain their own quotation marks, so that some of the cross-refs turn out as: "1.1 This is "another" example"
What happens when using the GREP? It would stop at the first right quotation mark. I have tried a lot, but I cannot find the correct extension for my GREP, to sort of skip both or all of the inner quotation marks.
Anyone has a solution, other than to replace the double quotation marks in the headlines by single ones? This would of course solve the problem. Thanks in advance.
Those 'unconditional' spaces are in fact variable-width non-breaking spaces. You use ~S for them in a grep expression.
Copy link to clipboard
Copied
As a nasty addition, in a French document the quotation marks are followed/led by an unconditional space, put by the translator:
I also couldn't find a wildcard or placeholder that would include that unconditional space. (") (\d+.+?) (.+?) (") and (".)(\d+.+?) (.+?)(.") don't work.
Copy link to clipboard
Copied
Those 'unconditional' spaces are in fact variable-width non-breaking spaces. You use ~S for them in a grep expression.
Copy link to clipboard
Copied
Thanks. As I'm currently digging deeper into GREP than ever before, I have a lot to learn.
My thinking now was to OR the search to either find the quotation mark or the mark follow by that special space.
So I made this: (["]|["~S])(\d+.+?) (.+?)([~S"]|["])
It works, but for the French document it now wouldn't include the outer quote anymore.
I actually don't see why, because only ["~S] and [~S"] fulfill the pattern.
Update: this seems to do it: ("|"~S)(\d+.+?) (.+?)(~S"|")
Copy link to clipboard
Copied
I don't understand your "|" at all. The expression works, but I've no idea why and how.
To match the number, instead of (\d+.+?) it feels safer to use [\d.]+
Also, you need parentheses for grouping only if you reference the groups. Leaving them out when they're not needed makes the expression more readable. Here's a simpler version of your expression:
"~S[\d.]+ .+?~S"
> I have a lot to learn.
It's worth all your trouble. There are various web sites with training material. For a comprehensive guide, see https://creativepro.com/now-available-grep-in-indesign-3rd-edition/
Copy link to clipboard
Copied
I don't understand your "|" at all. The expression works, but I've no idea why and how.
As far as I learned, everything after the | is used, until delimited. So it's, in words, "quotation mark OR quotation mark followed by unconditional space".
Copy link to clipboard
Copied
Oops! Of course! But in your "|"~S it means 'quotation mark OR quotation mark, followed by ~S', which doesn't make much sense and explains why the closing quote isn't found. Your [~S"]|["] says '~S or quote followed by quote'. Remember that [~S"] and ~S|" are equivalent.
Copy link to clipboard
Copied
Remember that [~S"] and ~S|" are equivalent.
Hmm... I knew that, but had in mind the expression in brackets is AND, not OR.
Copy link to clipboard
Copied
The character class is tested against single characters, which can only be one OR the other.
Copy link to clipboard
Copied
To match the number, instead of (\d+.+?) it feels safer to use [\d.]+
I think that wouldn't include two- or three-digit numbers.
Copy link to clipboard
Copied
It would. It's a character class, saying 'a string consisting of digits and/or dots'.
Copy link to clipboard
Copied
There is a grep modifier to find matching characters (brackets, quotation marks) but they won't help you here I don't think.So you'd probably need a script for things like "1.1 This is "another" example"
Find more inspiration, events, and resources on the new Adobe Community
Explore Now