- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2018 02:54 AM
I have created one regex as Below in fix Script.
Here I need to check after @ ,MY-mobile.COM should be there.
Its working but as case sensitive
also i used (?i) but its not working in servicenow
My code Is Below:
var regex = /MY-mobile.COM(?!@)$/;
gs.print(regex.test('om.dave@MY-mobile.COM')); // TRUE
gs.print(regex.test('om.dave@my-mobile.COM')); // False (Case Sensitive )
Thanks in advance .
Thanks
Om Dave
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2018 12:44 AM
Hi Dave,
You should add "i" flag at the end of your regex, and mask the dot (cause otherwise the dot would match with any character) like this:
var regex = /MY-mobile\.COM$/i;
gs.print(regex.test('om.dave@MY-mobile.COM'));
gs.print(regex.test('om.dave@my-mobile.COM'));
//*** Script: true
//*** Script: true
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2018 12:44 AM
Hi Dave,
You should add "i" flag at the end of your regex, and mask the dot (cause otherwise the dot would match with any character) like this:
var regex = /MY-mobile\.COM$/i;
gs.print(regex.test('om.dave@MY-mobile.COM'));
gs.print(regex.test('om.dave@my-mobile.COM'));
//*** Script: true
//*** Script: true
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2018 10:04 PM
Thanks Vitaly.