How to use regex validation for a specific number? | XM Community
Skip to main content

Apologies for silly questions from a newcomer will no programming knowledge.

I am trying to get respondents to key in specific numbers as an exercise to test their understanding. I have tried two options of validation for text entry and both failed.

To provide an example, if one specific answer that respondents should key in is 150.

 

Option 1 (failed attempt): I tried using content validation → number. However, the validation message reveals the correct answer 150, which should not be shown to respondents. A possible solution is to get rid of this message. Any ideas on how to do this please?

 

Option 2 (failed attempt): I tried custom validation -> match regex, but I am not sure what to type into the box after match regex. A few things that I have tried but failed include as follows:

(i) / 150 /

(ii) ^150$

(iii) \b150\b 

Any advice would be greatly appreciated. Thank you!

@ysp Check out this previous post, it might help you I believe.

 Help with Regex validation | XM Community (qualtrics.com)


@ScottG : Thanks for your reply!  I did see the post before posting my inquiry. However, they are looking at matching a random number with a specific number of digits, but I am looking to match a specific number so it doesn’t work. Appreciate your help anyways, thanks!


Hi @ysp 
Do a small change in your ‘Option 2’ approach. Instead of using regex custom validation, please specify that the text entry should be '150'. Additionally, you can customize the error message as per your preference, either using default ones or creating a customized message from your library.

 


@omkarkewat : Thank you sooooooo much! It worked. I tried this yesterday but must have done something wrong because it didn’t work, and I thought that was because text entry doesn’t recognize numbers. Thank you sooooooooooooooo much again!


@omkarkewat thank you.  I have been meaning to come back to this the last few hrs, so appreciate you jumping in to help resolve it :)


Leave a Reply