Help with Regex validation | XM Community
Skip to main content

Hi all,
I've been struggling with some regex validation. I'm building a survey that has a text entry field, and the entry has to follow the format:

##/#####

That is, it must be 2 numbers followed by a forward slash "/" followed by 5 more numbers. I thought the below regex would work, but unfortunately it isn't.

[0-9]{2} [\\/] [0-9]{5}

Can anyone tell me what the regex expression needs to be?

You appear to have spaces in your regex. Should work if you remove them.
Learn more here: https://regex101.com/


Hi ahmedA,
Removing spaces didn't fix the problem :(


Share a screen grab of what you are entering and the settings.


I solved my problem and in good forum etiquette I'm posting the solution in case anyone else ever has the same problem.
The solution is:

^[0-9]{2,2}[\\/][0-9]{5,5}$

Just another watch out, I had a setting wrong in my Custom Validation. I previously had it set to "Is Equal to". I think when you click in and out of custom valuation, it automatically resets to "Is Equal to". The setting you need is "Matches Regex".
Image attached.
image.png


Regex can be brutal though with ChatGPT it has made the process easier at least for me.  I’ve always found it easier to just use JavaScript for data validation in the Qualtrics OnLoad section. These forums helped me awhile back with that. 

If anyone is curious how to do custom data validation with JavaScript in Qualtrics,  I made a video to walk you through two examples (links to the JavaScript code also provided). 
 

 


Leave a Reply