Copy link to clipboard
Copied
Hello.
I have a long list of words (one word per line) like so:
"Pothole
Painting
Comb
School
Tent
Ring"
I want to apply character style to all the words that contain letters "n", and extract those words to a new indesign file.
Please help.
Thanks and regards.
Does this Grep helps you?
[\l\u]*[nN]+[\l\u]*
For exporting the matched words to a file you can use the following script
var doc = app.documents[0]
app.findGrepPreferences.findWhat = "[\\l\\u]*[nN]+[\\l\\u]*"
var f = doc.findGrep()
app.findGrepPreferences.findWhat = NothingEnum.NOTHING
var s = ""
for(var i = 0; i < f.length; i++){
s += f[i].contents + "\n"
}
if(s != ""){
var f = new File("~/Desktop/out.txt")
f.open("w")
f.write(s)
f.close()
}
I could not make your regex work so I used @pixxxelschubser's regex. You ca
...Copy link to clipboard
Copied
Does this Grep helps you?
[\l\u]*[nN]+[\l\u]*
Copy link to clipboard
Copied
Thanks for the reply.
[\w]*[nN]+[\]*
this grep pattern worked for me.
Kindly help with the extraction of all matching words to a new file as well.
I can guess that this involves some kind of script.
Thanks.
Copy link to clipboard
Copied
For exporting the matched words to a file you can use the following script
var doc = app.documents[0]
app.findGrepPreferences.findWhat = "[\\l\\u]*[nN]+[\\l\\u]*"
var f = doc.findGrep()
app.findGrepPreferences.findWhat = NothingEnum.NOTHING
var s = ""
for(var i = 0; i < f.length; i++){
s += f[i].contents + "\n"
}
if(s != ""){
var f = new File("~/Desktop/out.txt")
f.open("w")
f.write(s)
f.close()
}
I could not make your regex work so I used @pixxxelschubser's regex. You can change the regex to what you want in the code in line no. 2, just make sure you escape \. The script will create a file names out.txt on the desktop
-Manan