REGEX for Range Validation | XM Community
Skip to main content
Solved

REGEX for Range Validation

  • November 2, 2023
  • 4 replies
  • 47 views

Forum|alt.badge.img+2
  • Level 2 ●●
  • 21 replies

i have created at transposed multi punch matrix question and now i have to apply a validation to make sure that respondent should select more than 5 options but less than 10. How can i compare recode values using regex by referring to commas. I m thinking if 4-9 commas in recode value then it’s fine else we should show error message. How can i write regex to check 4-9 commas in recode values.

Best answer by TomG

Use this regex: ^(\d+\,){4,9}\d+$

 

4 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 6083 replies
  • Answer
  • November 2, 2023

Use this regex: ^(\d+\,){4,9}\d+$

 


Nam Nguyen
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+29
  • QPN Level 8 ●●●●●●●●
  • 1096 replies
  • November 2, 2023

@Salim Use ^(?:[^,]+,){4,9}[^,]+$


Forum|alt.badge.img+2
  • Author
  • Level 2 ●●
  • 21 replies
  • November 2, 2023

Use this regex: ^(\d+\,){4,9}\d+$

 

Thanks, it worked.


Forum|alt.badge.img+2
  • Author
  • Level 2 ●●
  • 21 replies
  • November 2, 2023

@Salim Use ^(?:[^,]+,){4,9}[^,]+$

Thanks