Copy link to clipboard
Copied
I've written a command in my FindChangeByList file, but I don't know why it's not working. Here's the code:
grep {findWhat:"(\bX\b)[~m~>~f~| ~S~s~j~<~/~.~3~4~%]{1,}(\bY\b)"} {changeTo:"$1$2"} {includeFootnotes:true, includeMasterPages:false, includeHiddenLayers:true, wholeWord:false}
It's supposed to find the words X and Y with whatever ant any number of spaces between them, and put them together. I think the problem may be related to the \b command inside the parentheses because when I delete them, it's working.
Besides, is it possible to have a dialog box in the jsx file to see the number of changes that the FindChangeByList has made at the end of running?
@Pickory: I think you are right. When I dragged the files from the script folder to the dropbox folder they duplicated without me holding down the Option key. I was surprised but then didn't think anything more about it. 🙄
@SunFlower16 Try this link. I'm around for a few hours in case it doesn't work. Just let me know.
https://www.dropbox.com/scl/fo/eg6rsi5qd5d9wxbevtqec/h?dl=0&rlkey=hb2szz71d7s6jzffdsvrmp612
~Barb
Copy link to clipboard
Copied
I suppose you will have to escape the \ so \b would be \\b. Try it hopefully it will work
-Manan
Copy link to clipboard
Copied
I tried but it didn't work, I'm afraid. Could you please give it a try?
Copy link to clipboard
Copied
Hi @SunFlower16:
All of the backlashes need to be escaped as per this line in the file:
Copy link to clipboard
Copied
Could you kindly please provide me with your file or your code? I couldn't manage to do it maybe because I'm a newbie.
Here's my file:
https://drive.google.com/file/d/1ziJgxaqWSYzOiDec_UqFCtEWn_lsLYq3/view?usp=sharing
Note that my file is a combination of the JSX and the TXT file, so it's standalone.
Copy link to clipboard
Copied
Hi Brad:
Here is a link to the two files I created to answer your question.
https://www.dropbox.com/sh/5gbghni11clyfsy/AABCg7p5pBDpjfvzpxbQgh3Ka?dl=0
Put the .jsx file in the JavaScript folder. Put the .txt file in the JavaScript\FindChangeSupport folder. Note: if you change the file names, you will need to change the reference to the .txt file in the .jsx file.
~Barb
Copy link to clipboard
Copied
Your txt file seems corrupted. Could you kindly please double-check?
Copy link to clipboard
Copied
Hi Barb,
It looks like you might have copied file alias to dropbox.
P.
Copy link to clipboard
Copied
@Pickory: I think you are right. When I dragged the files from the script folder to the dropbox folder they duplicated without me holding down the Option key. I was surprised but then didn't think anything more about it. 🙄
@SunFlower16 Try this link. I'm around for a few hours in case it doesn't work. Just let me know.
https://www.dropbox.com/scl/fo/eg6rsi5qd5d9wxbevtqec/h?dl=0&rlkey=hb2szz71d7s6jzffdsvrmp612
~Barb
Copy link to clipboard
Copied
Thanks a million dear Barb. It's working properly.
@Barb Binder @Pickory I also modified my own code. To my surprise when I implemented both //.source and the escaped backslash, it started working. I mean I wrote this:
{findWhat:/(\\bX\\b)\\h+(\\bY\\b)/.source}
I really don't know why, but it's up and running too.
Copy link to clipboard
Copied
You can give all the credit to @Manan Joshi. He taught me everything I know about Find/ChangeByList! 😊
~Barb
Copy link to clipboard
Copied
Ok, @SunFlower16 ,
findWhat is expecting a string.
With /myRegExp/.source it gets a string, because the regular expression, the RegExp, is "converted" (coerced) to a string.
Hm…
/\n/.source === "\\n";
Returns true. The expression on the left of the tripple = is identical to the expression on the right.
So double-escaping should not be necessary.
One could test this with full ExtendScript code for InDesign to populate the GREP Find field in the GUI. Run this code:
app.findGrepPreferences.findWhat = /\n/.source;
Look up the result in the GUI under the GREP Find field:
So:
app.findGrepPreferences.findWhat = /(\bX\b)\h+(\bY\b)/.source;
will show up like this:
The same should happen with the list in FindChangeByList.
Either do that:
grep {findWhat: "(\\bX\\b)\\h+(\\bY\\b)"}
or write it this way:
grep { findWhat : /(\bX\b)\h+(\bY\b)/.source }
With ExtendScript this expression will return true:
"(\\bX\\b)\\h+(\\bY\\b)" === /(\bX\b)\h+(\bY\b)/.source // will return true
Regards,
Uwe Laubender
( Adobe Community Professional )