- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2023 10:37 PM
Dear Community,
On the Service catalog form we ask users for provide FQDM/Fully Qualified Domain name (www.example.com, www.example.co.uk, etc). ServiceNow has out-of-the box Regular expression for URL, however it contains "http". Which regular expression should be used to check user provided URL in FQDM format only, no additional characters allowed. Thanks!
Regards,
Mantautas.
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 04:14 AM
Valid point! 🙂 Try this:
/^(?!:\/\/)(w{3}+\.)?[a-zA-Z0-9][a-zA-Z0-9-]+\.[a-zA-Z]{2,6}?$/ji
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 08:10 AM
Perhaps this minor change at the end would do:
^(?!:\/\/)(w{3}+\.)?[a-zA-Z0-9][a-zA-Z0-9-]+\.[a-zA-Z\.]{2,6}?$
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 02:31 AM
There's plenty of examples online, but this worked fine for me:
/^(?!:\/\/)([a-zA-Z0-9]+\.)?[a-zA-Z0-9][a-zA-Z0-9-]+\.[a-zA-Z]{2,6}?$/i
Here's a test:
var r = new RegExp('^(?!:\/\/)([a-zA-Z0-9]+\.)?[a-zA-Z0-9][a-zA-Z0-9-]+\.[a-zA-Z]{2,6}?$', 'ji');
var testString = 'www.testpage.com';
gs.info(testString.match(r) ? 'match' : 'does not match');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 02:32 AM
Forgot to mention, the 'j' flag is only added to tell the engine to treat this expression as a Java expression. It can be dismissed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 04:04 AM
Thanks a lot Laszlo!
This expression would allow to put any letters on "www" part.
For example zzz.testpage.com..Also more that 3 letters would be accepted, for example "wwww.testpage.com". How do i control the "www" piece, so its only 3 letters allowed and only 3W 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 04:14 AM
Valid point! 🙂 Try this:
/^(?!:\/\/)(w{3}+\.)?[a-zA-Z0-9][a-zA-Z0-9-]+\.[a-zA-Z]{2,6}?$/ji