Wednesday, September 16, 2020

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

 




As we are using Madrid 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.

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.







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}$

Reference : 


More details on similar topic I have kept in portal  - https://www.servicenowpreparation.com/ you can visit.

Bel
Happy Learning

Regards
Sandeep Kumar


No comments:

Post a Comment