- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 11:20 AM
Hi all,
I am trying to use Matches Regex Condition Builder for Assignment Rules. I get a match when I use https://regex101.com/ to build the expressions however the same expression doesn't seem to work in ServiceNow.
Use case:
Applies To - Table ==> Incident ; Conditions ==> Short Description matches regex /example/i
Assign To - Group ==> Assignment Group 1
So basically any incident which contains "example" in the short description irrespective of the case should assign to Assignment Group 1.
Thanks,
Swati
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 11:14 AM
@SwatiYeginati Here is another alternative for you if case insensitive contains doesn't work on Assignment rule.
Create a scripted Assignment rule as follows.
if(current.short_description.toLowerCase().indexOf('example')>-1){
current.assignment_group.setDisplayValue("Hardware"); //Replace with your Assignment group name
current.assigned_to.setDisplayValue('ITIL User'); //Replace with your assignee name
}
This assignment rule will run for all the variants of Example/example/EXample. I have tested this solution on my PDI and it works fine for different combinations.
Hope this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 08:34 PM
@SwatiYeginati I have seen a couple of user's complaining about the Matches Regex option in condition builder. One such thread is mentioned here https://www.servicenow.com/community/developer-forum/match-regex-in-condition-builder/m-p/2108987/pa....
Another alternative suggested on the thread to get this working via a regex matching inside a script include and calling that script include in the condition builder.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 06:57 AM
Hi Sandeep,
I have been through that thread. I do not wish to create a script as the user mentions in the thread. Also, there's a solution in the thread as copied below:
"You have to escape twice i.e \\b so to the match function received \b as the anchor for word in regex. Its old no one answered it so, I just answered if someone need it in the future. HTH
Thanks,
DC" ,
I am not sure how to use this solution. I tried it in different ways but it didn't work. Can you please explain it to me?
Thanks,
Swati

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 08:21 AM
According to my understanding the poster asked to use additional / character in the regular expression string so instead of /example/i your expression will look like //example//i, but I doubt if this will work.
As recommended by the other poster, I highly recommend using contains filter instead of the matches regex as contains search is already case insensitive so you wouldn't have to create variations of your text.
For e.g. even if the example is written as Example or EXample or EXAMPLE the contains search would find all the matches regardless of the fact in which case (capital case/small case) they are written.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 09:17 AM - edited 07-25-2023 10:37 AM
Sorry, Sandeep but "contains" is case-sensitive. I tested it with the assignment rule and it didn't work as you mentioned. Is there a way to make it case-insensitive?