Custom RegEx in Transform and compose section of event rule not working

Ganeshm1
Tera Guru

Hi All,

I have configured custom RegEx to extract the required information in an event. 
Whenever I am trying to add the below RegEx expression in event rule, its asking two fields to select. 

Regex is working as expected in Regex101.com (Green color background is the one which I need as output)

Ganeshm1_1-1725957120472.png

 

In instance its asking two expression to select or add while i am using the custom regex. Can anyone help me how I can address this?

Ganeshm1_0-1725957067239.png

 

Regards,
Ganesh

1 ACCEPTED SOLUTION

Hey,

have you tried matching it without any grouping?

Something like: \S+\s+\S+\s+\S+\s+(\S+)

 

Maybe the issue is something else.


Regards

Fabian

View solution in original post

5 REPLIES 5

Fabian Kunzke
Kilo Sage
Kilo Sage

Hey,

This is caused by how ServiceNow interprets RegEx, which is differently from other common regex testers. ServiceNow seemingly has difficulty utilizing non-capturing groups and instead seems to think you "non-capturing" group is also something you want to extract.

 

The easiest fix is to just roll with it IMO. It's not great, but just give the first (non capturing group) a meaningless attribtue. This is also summarized here: Event Management - Event Rules - Regex Parser How-To - Support and Troubleshooting (servicenow.com)

 

Recommendation: Just ignore the groups you don't need.

 

This is why it asks you for 2 attributes. Just "ignore" the first one you set and use the second one.

 

Regards
Fabian

Hello @Fabian Kunzke 
Thank you for your reply. Event after ignoring the group I don't want and mapped the group which is necessary, I am getting empty value in output. Any thoughts on this?

RegEx is working as expected in https://www.freeformatter.com/java-regex-tester.html#before-output

 

Regards,
Ganesh 

Hey,

have you tried matching it without any grouping?

Something like: \S+\s+\S+\s+\S+\s+(\S+)

 

Maybe the issue is something else.


Regards

Fabian

Thank you @Fabian Kunzke . It worked.