Well, as Jongware always says, GREP is greedy, and always want's to pick up as much as expression allows.
Simply add question mark after plus sign, and you will get the result you are expecting.
app.findGrepPreferences.findWhat = "(\\^I\\^)(.+?)(\\^/I\\^)";
Hope that helps.
Fantastic! Works beautifully!
Thanks for that.
You should add the singleline mode operator (?s) to the grep to deal with multiple paragraphs
app.findGrepPreferences.findWhat = "(?s)(\\^I\\^)(.+?)(\\^/I\\^)";
could also use look ahead and look behinds to only select the text between the tags
app.findGrepPreferences.findWhat = "(?s)(?<=<I>).+?(?=</I>)";
I see the second method is not apropriate in this case
Message was edited by: ~ Trevor ~
Thanks Trevor. I've added the singleline mode operator because that makes it even more robust (and, although unlikely to occur in this particular project, is guaranteed to be the next thing the client picks up on...)