Find a value between two strings using regex

Aidan
Tera Guru

(originally posted under Now Platform)

I'm looking to parse a script field to find any messages that have been referenced in gs.getMessage() calls.  The following regex works fine in any online test website but not in ServiceNow;

(?<=getMessage\(\").*?(?=\")

Here's the code I'm trying to use;

var regex = new RegExp(/(?<=getMessage\(\").*?(?=\")/g);

which returns the following error when tested/exec'd

Evaluator: com.glide.script.RhinoEcmaError: Invalid quantifier ?
   Line(0) column(0)

Looks to me like the Positive Lookbehind is failing, but not sure of an alternative.

 

5 REPLIES 5

maybe you could do a split('getMessage');  Then index 0 should be the message.