Validation Regex is not working

Prudhvi Raj4
Tera Guru

Hi Team,

 

I have created a Validation Regex for the one of the single line text variable, but it was giving error when I enter the correct expression as well. I am checking for alphanumeric with hyphens in between. Below is the code using.

  Validation Regex

PrudhviRaj4_0-1674642977557.png

Result form above validation

PrudhviRaj4_1-1674643023830.png

Error popping up for correct values as well.

 

Thanks,

Prudhvi

1 ACCEPTED SOLUTION

Gunjan Kiratkar
Kilo Patron
Kilo Patron

Hi @Prudhvi Raj4 ,

Please try below regex

^(?:[A-Za-z0-9]{4}-){5}[A-Za-z0-9]{0,4}$

Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

View solution in original post

5 REPLIES 5

Brad Bowman
Kilo Patron
Kilo Patron

So close - use [] instead of ()

^[a-zA-Z0-9\-]*$	

Hi @Brad Bowman  

Yes, I have already tried it, so the result was, It was expecting any type of expression. If I give only number only no error and system takes it as correct expression

So what is your actual requirement - a certain number of alphanumeric characters PLUS a hyphen?  Must/will it always be 4-4-4-4-4-4 as pictured?

My Requirement is the field should have 24 characters alphanumeric value with a hyphen after every 4 characters 

Example: Ab12-CD34-fg45-Sf45-s1ft-1We4