Regular Expression to validate Domain Name

Mantautas
Tera Contributor

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.

2 ACCEPTED SOLUTIONS

Valid point! 🙂 Try this:

/^(?!:\/\/)(w{3}+\.)?[a-zA-Z0-9][a-zA-Z0-9-]+\.[a-zA-Z]{2,6}?$/ji

View solution in original post

Perhaps this minor change at the end would do:

^(?!:\/\/)(w{3}+\.)?[a-zA-Z0-9][a-zA-Z0-9-]+\.[a-zA-Z\.]{2,6}?$

View solution in original post

6 REPLIES 6

It works! Thanks a lot. Last question - what if domain consists of "www.example.co.uk" ? The current rule will not allow such address

Perhaps this minor change at the end would do:

^(?!:\/\/)(w{3}+\.)?[a-zA-Z0-9][a-zA-Z0-9-]+\.[a-zA-Z\.]{2,6}?$