Global Switch (/g) in RegEx parsing strategy in Pattern Designer

knightofmirrors
Kilo Contributor

Has anyone been able to successfully get the Global (/g) switch to work successfully in Pattern Designer for a RegEx parsing strategy?  

If I write a pattern that successfully is iterated using the Global switch and it tests correctly in a tool like Regexr, that same pattern won't match on subsequent iterations when I try with /g in the Pattern Designer.

I am trying to build a tabular variable and would like an additional row for each match of the pattern

Thanks!

Sean

1 ACCEPTED SOLUTION

Asi Garty
ServiceNow Employee
ServiceNow Employee

Hi,

Unfortunately the global switch is not supported, and the expression matchs each line separately.
The good news are that it is on the road map as a future enhancement.

If you are populating a table it will iterate through the entire text and add new table row for each successful (non global) match.

in order to globally match the entire text, you should write a pattern step with an eval statement and implement a simple java script that will run regexp match with any required flags.

Hope this helps.

If it does please mark if helpful and share your results.

Asi

View solution in original post

8 REPLIES 8

Asi Garty
ServiceNow Employee
ServiceNow Employee

Hi,

Unfortunately the global switch is not supported, and the expression matchs each line separately.
The good news are that it is on the road map as a future enhancement.

If you are populating a table it will iterate through the entire text and add new table row for each successful (non global) match.

in order to globally match the entire text, you should write a pattern step with an eval statement and implement a simple java script that will run regexp match with any required flags.

Hope this helps.

If it does please mark if helpful and share your results.

Asi

ASI that's a great idea however I've never been able to access and return a Tabular variable through EVAL scripting. Do you have an example?

knightofmirrors
Kilo Contributor

Asi thank you this was very helpful!

Hi Sean, thanks for the feedback.
Just mark it as helpful 🙂