Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Validation regex not working

Community Alums
Not applicable

Hi all,

Im trying to create a validation regex for a string field

regex is : 

^([a-zA-Z\d]{2}[-.][a-zA-Z\d]{4}[-.][a-zA-Z\d]{4}[-.][a-zA-Z\d]{3}|[a-zA-Z\d]{6}[-.][a-zA-Z\d]{3}[-.][a-zA-Z\d]{4}[-.][a-zA-Z\d]{1})$
 
The requirement is it should allow both formats below, and can contain numbers and letters(case insensitive) and delimters can be - or .
xx-xxxx-xxxx-xxx
xxxxxx-xxx-xxxx-x
 
when I run the above regex in background script, it works fine. But not in catalog item in portal
Can someone suggest me a solution, please
 
Thanks
Bimsari
5 REPLIES 5

Hi @Community Alums 

 

As @Mark Roethof  told, your regex is working as expected. I tried simulating this issue on my PDI and it worked as expected. Refer below steps and check if you missed anything :

 

1. Setup the Regex :

 

AmitVerma_0-1723444371351.png

 

2. Link it to your variable :

AmitVerma_1-1723444406016.png

 

Output :

 

AmitVerma_2-1723444460635.png

 

AmitVerma_3-1723444474621.png

 

Thanks and Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.