Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Regex not working in condition for filter

Alex1472
Tera Contributor

Hi there!

 

I'm currently struggling with the condition builder (filter) and a regex. I would like to filter out only a few words from a field. Since there are quite a few, I would prefer to use regex instead of "contains." However, I'm having trouble with it. I've tried several combinations, but none of them work.

For example, this regex: word1|word2|word3 (with "/", with parentheses, etc.). The filter works otherwise, but no regex.

 

Does anyone have an idea?

 

Thanks a lot!

3 REPLIES 3

Sandeep Rajput
Tera Patron
Tera Patron

@Alex1472 This could be the possible explanation.

 

Screenshot 2025-04-04 at 6.25.22 AM.png

Here is the link to KB article https://support.servicenow.com/kb?id=kb_article_view&sys_kb_id=0c3d8ec2db6076000e3dfb651f961911

Vishal Jaswal
Giga Sage
Giga Sage

Hello @Alex1472 

 

If there are some things in ServiceNow that can break your trust then regex in condition filter is one.

 

Anyways, I use regexr website to build regex and below is what I found:

 

\b(word1|word2|word3)\b

 

 

\b is for partial matches like it can find word123

 

Try using a wildcard pattern as shown below and see if it works for you or not:

 

.*(word1|word2|word3).*

 


Hope that helps!

Alex1472
Tera Contributor

Hi guys!

Thank you very much! I tried all of this, but it didn't work either. It seems like regex doesn't work at all in the condition builder. I will then go with my original solution.