Find a value between two strings using regex

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2019 11:01 AM
(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

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2019 07:27 AM
maybe you could do a split('getMessage'); Then index 0 should be the message.