logo

NJP

OOB Regex Validation for Currency || Email || IP address || Letter || Mac address || Number || URL

Import · Mar 03, 2020 · article

Thanks to Mark Roethof image

image

As we are using Madrid or NewYork version of ServiceNow. I have come across one OOB feature of ServiceNow in Madrid for validating below

Currency || Email || IP address || Letter || Mac address || Number || URL

We have a table in ServiceNow called Questions Regular Expression “question_regex”. Which store the regular expression in record format. See below.

image

OOB we only three validation but we can create as many as we want with the help of Regex.

Once we create a record in Questions Regular Expression “question_regex” table we can put that validation while creating variable in Catalog item.

See below: This works on Single line text field.

image

No more writing lengthy script for validation.

Below are the Regex validation we can utilize

- Currency ($)\$[0-9]*\.[0-9]{2}$- Currency (€)\€[0-9]*\.[0-9]{2}$- Email address\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$- IBAN[a-zA-Z]{2}[0-9]{2}[a-zA-Z0-9]{4}[0-9]{7}([a-zA-Z0-9]?){0,16}$- IP address\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b$- Letter (A-z)[A-Za-z]*$- Mac address[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}$- Zip Code (NL)

[1-9][0-9]{3}[\s]?[A-Za-z]{2}$

View original source

https://www.servicenow.com/community/developer-articles/oob-regex-validation-for-currency-email-ip-address-letter-mac/ta-p/2321324