Copy link to clipboard
Copied
Hi grep and script experts;
I want to select all paragraphs that start with a number and end with "END". But I can't select all of them because there is a table in the paragraph. Can you help me?
This is a known problem: the dot doesn't match the table character (U+0017). The dot doesn't match the footnote marker either, but at least there's a workarounf for that. That workaround doesn't work for tables though. The problem is that even a GREP search for the table character (look for \x17 or \x{0017}) won't find anything. (In the Text tab you can look for <0017>, which does find tables.)
The only way I know of to deal with this is to find all ^\d, then find all END\r, and process the te
...As you can see in the Grep F/R [french] window, I use the Grep Code provided by the op [I've just added a "?" to make the Found more precise, but the op's code remains correct]. My Script is based on this Grep F/R with finally 4 Found!
(^/)
Copy link to clipboard
Copied
This is a known problem: the dot doesn't match the table character (U+0017). The dot doesn't match the footnote marker either, but at least there's a workarounf for that. That workaround doesn't work for tables though. The problem is that even a GREP search for the table character (look for \x17 or \x{0017}) won't find anything. (In the Text tab you can look for <0017>, which does find tables.)
The only way I know of to deal with this is to find all ^\d, then find all END\r, and process the text between these start and end points. Along these lines:
app.findGrepPreferences = null;
app.findGrepPreferences.findWhat = '^\\d';
starts = app.activeDocument.findGrep();
app.findGrepPreferences.findWhat = 'END\\r';
ends = app.activeDocument.findGrep();
if (starts.length !== ends.length) {
// Log a problem
exit();
}
for (i = starts.length-1; i >= 0; i--) {
fragment = starts[i].parentStory.characters.itemByRange (
starts[i].index, ends[i].index+4
);
// Now do something with the fragment
process (fragment); // To be defined
}
Copy link to clipboard
Copied
Thank you @Peter Kahrel
I have confirmed that the grep code is not working. I will have to continue with the script.
Copy link to clipboard
Copied
Why do you want to select these texts? [to make what…]
(^/) The Jedi
Copy link to clipboard
Copied
Aside from potential bugs, your screen shot shows that there are no paragraphs that actually start with a digit and end with END. There are 4 distinct paragraphs in that story: The first is empty, the second starts with 15 and ends at the hyphen before the table, the third contains only the table, and the fourth ends with the word END, but starts with Velis, not a number.
That might not be the only reason the GREP fails to find a match, but there ceertainly is none to find here.
Copy link to clipboard
Copied
As you can see in the Grep F/R [french] window, I use the Grep Code provided by the op [I've just added a "?" to make the Found more precise, but the op's code remains correct]. My Script is based on this Grep F/R with finally 4 Found!
(^/)
Copy link to clipboard
Copied
Hi FridNGE;
I want to give a single paragraph style to all paragraphs. Including the text inside the table. I also want to give a condition to all text. Grep doesn't work for me but it seems to work for you...
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hi @Robert at ID-Tasker r
I know but it doesn't work that way either...
Copy link to clipboard
Copied
Hi @Robert at ID-Tasker r
I know but it doesn't work that way either...
By @uniq1
For me neither...
What your script is doing exactly?
Can you post its contents?
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more