Reply To: Grep code works inside indesign but not in script

#85311
Ari Singer
Member

Whenever you include a backlash within quotes in a script, the script will get confused. For example, if you write: findWhat: "\r" JavaScript will think that you want to insert an actual return in that string (because that’s the way it’s done in JavaScript). So whenever you include a GREP query in a script, any backslashes have to be escaped again. So instead of \r it has to be r.

In other words, for every backslash: one more. (except when you already have two backslashes, such as when you’re searching for an actual backslash, then you have to write three backslashes, not four.

So in your case, that would be like this:

{findWhat:”(s)(d+.d+)(,s)(d+.d+)(,s)(d+.d+)(,s)(d+.d+)(s)”} {changeTo:”t$2t$4t$6t$8t”} {}

This article was last modified on May 31, 2016

Comments (0)

Loading comments...