Copy link to clipboard
Copied
I have a file I need to find the textFrames that have " - #” x #”" in the frame. Using the F/C GREP I can find them with / - d+.d+” x d+.d+”/. If I try to using it in my script it does not give anything back on the same text frames.
The lines of code where this is used are:
1 Correct answer
Yes, including the period. Something like this:
var doc = app.activeDocument;
app.findGrepPreferences = NothingEnum.NOTHING;
app.findChangeGrepOptions.properties = {
includeFootnotes: false,
includeHiddenLayers: false,
includeLockedLayersForFind: false,
includeLockedStoriesForFind: false,
includeMasterPages: false,
searchBackwards: false,
};
app.findGrepPreferences.properties = {
findWhat: '\\d+(\\.\\d+)?[”"] x \\d+(\\.\\d+)?[”"]',
};
var found = doc.findGrep();
$
...
Copy link to clipboard
Copied
You need to escape the backslashes, ie \\d
Copy link to clipboard
Copied
Yes, including the period. Something like this:
var doc = app.activeDocument;
app.findGrepPreferences = NothingEnum.NOTHING;
app.findChangeGrepOptions.properties = {
includeFootnotes: false,
includeHiddenLayers: false,
includeLockedLayersForFind: false,
includeLockedStoriesForFind: false,
includeMasterPages: false,
searchBackwards: false,
};
app.findGrepPreferences.properties = {
findWhat: '\\d+(\\.\\d+)?[”"] x \\d+(\\.\\d+)?[”"]',
};
var found = doc.findGrep();
$.writeln('found.length = ' + found.length);
for (var i = 0; i < found.length; i++) {
$.writeln(found[i].contents);
}
Not sure if you need it, but matching typographic quotes might be useful, too.
- Mark
Copy link to clipboard
Copied
Thank you! GREP is still magic to me.
Copy link to clipboard
Copied
Note that you only have to escape them in script. In the find change panel it would still be \d, etc.
Copy link to clipboard
Copied
Oh, I know. I had worked it out in the find change panel until it worked, then pasted it over and had the issues.

