Copy link to clipboard
Copied
I'm trying to find periods with zero or more whitespace characters after them. Everything I can find says this should work, but it doesn't work for strings that have no whitespace (looking for a capital letter followed by a period):
I don't think that the problem is with your query. Maybe something else is going on somewhere else in your script? Your query seems to work for me, at least when I put it in the simplest script possible:
Hi @Thomas_Calvin , It’s also working for me with ExtendScript. Here it is via a function:
grepSearch("^[A-Z]\\.\\s*", "B. ")
/**
* Document Grep find and change
* @ param f the find grep string
* @ param c the change grep string
* @ return void
*/
function grepSearch(f,c){
app.findGrepPreferences = app.changeGrepPreferences = app.findChangeGrepOptions = null;
app.findChangeGrepOptions.properties = app.findChangeGrepOptions.properties = {includeFootnotes:true, includeHiddenLayers:Copy link to clipboard
Copied
How about:
\u\.\s*
~Barb
Copy link to clipboard
Copied
Oh darn. I focused on your GREP expression as per your title, and missed that you need this included in a script. Not sure that my answer will be helpful. Sorry!
~Barb
Copy link to clipboard
Copied
I appreciate it Barb! I have a working script and a mostly-working expression. But the asterisk doesn't work.
Copy link to clipboard
Copied
It turns out that the UXP dev tool wasn't reloading the script when saved, despite "watch" being on. Restarting everything fixed it and the asterisk works fine!
Copy link to clipboard
Copied
The ens should be \\s+? I think
Copy link to clipboard
Copied
Thanks for the reply. Everything I've looked at says + means "one or more" not zero or more.
Copy link to clipboard
Copied
I don't think that the problem is with your query. Maybe something else is going on somewhere else in your script? Your query seems to work for me, at least when I put it in the simplest script possible:
Copy link to clipboard
Copied
Yep, thanks. It turns out that it works fine for me too. The UXP developer tool neglected to reload the source after I changed and saved it, despite "watch" being on. Usually this works fine. I noticed the wrong expression being used when stepping through with the debugger.
Copy link to clipboard
Copied
Noticed you tagged 'UXP Scripting' - are you writing a UXP script?
It might need to be something like this
/^[A-Z]\.\s*/
Copy link to clipboard
Copied
It is a UXP script. A plug-in, in fact.
Copy link to clipboard
Copied
Hi @Thomas_Calvin , It’s also working for me with ExtendScript. Here it is via a function:
grepSearch("^[A-Z]\\.\\s*", "B. ")
/**
* Document Grep find and change
* @ param f the find grep string
* @ param c the change grep string
* @ return void
*/
function grepSearch(f,c){
app.findGrepPreferences = app.changeGrepPreferences = app.findChangeGrepOptions = null;
app.findChangeGrepOptions.properties = app.findChangeGrepOptions.properties = {includeFootnotes:true, includeHiddenLayers:true, includeMasterPages:true, wholeWord:false}
app.findGrepPreferences.findWhat = f;
app.changeGrepPreferences.changeTo = c;
app.activeDocument.changeGrep( true )
}
Copy link to clipboard
Copied
Thanks Rob.
In the end, it works fine. The UXP developer tool did not pick up my source-code changes for some reason (despite "watch" being on), and was running an old version that didn't have the asterisk.
Copy link to clipboard
Copied
Yes, you found out the hard way that the UXP developer tool can't save changes you made to the code. It's pretty awful, but that's the way it is.
Copy link to clipboard
Copied
Actually, it usually does reload immediately after I save the file in VS Code. This is the first time I've seen it fail at that.
The really offensive part is the fake "editor" the UXP tool presents and allows you to "edit" and "save" the file in. This is mind-boggling. Why do they deliberately waste customers' time with this? There's no excuse for it.
Copy link to clipboard
Copied
Join the crowds. Here you can vent your ire:
https://forums.creativeclouddeveloper.com/c/uxp-developer-tool/65
And here you can log bugs and feature requests:
https://indesign.uservoice.com
Find more inspiration, events, and resources on the new Adobe Community
Explore Now