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

How to use regex validation for a specific number?

  • Jan 14, 2024 2:06 PM UTC
  • 5 replies
  • 459 views

Forum|alt.badge.img+1

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!

Best answer by omkarkewat

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.

 

View original

5 replies

Forum|alt.badge.img+34
  • Level 6 ●●●●●●
  • Jan 14, 2024 10:15 PM UTC

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

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


Forum|alt.badge.img+1
  • Author
  • Jan 15, 2024 2:18 AM UTC

@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!


Forum|alt.badge.img+23
  • QPN Level 5 ●●●●●
  • Answer
  • Jan 15, 2024 4:37 AM UTC

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.

 


Forum|alt.badge.img+1
  • Author
  • Jan 15, 2024 5:15 AM UTC

@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!


Forum|alt.badge.img+34
  • Level 6 ●●●●●●
  • Jan 15, 2024 6:12 AM UTC

@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 :)