Quantcast
Channel: Adobe Community : Popular Discussions - InDesign Scripting
Viewing all articles
Browse latest Browse all 15932

Modifying findGrep results when using lookaheads/lookbehinds [JS][CS6]

$
0
0

Dear all,

 

I am thinking about a search/replace script (JS) in which the user is able to choose in a GUI to which elements of a findGrep()-array a changeGrep() method should be applied to. All in all that should be an easy thing to do.

 

The only thing I am wondering about is dealing with lookaheads and lookbehinds. Assuming the findWhat expression to be " (?=!)" to find a single unwanted space in front of an exclamation mark. Please understand this just as a simple example, it is obvious that you can do that kind of simple search without using a lookahead. The findGrep array will contain the pointer to the found space. If the user decides to remove the space and applies the changeGrep method on it, no changes will be made because the exclamation mark is not stored in the findGrep array and hence changeGrep method will not match the space.

 

So I am thinking of extending the pointer/selection before using changeGrep to include the exclamation mark in order to successfully apply changeGrep. But maybe there is a more straight solution I am not aware of?

 

Would be glad to read your point of view here.

 

Thank you very much!

 

Jan


Viewing all articles
Browse latest Browse all 15932

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>