I'm trying to validate the inputs for a multiple short text question in my survey.
The question requires an answer:
- Between 2 and 3 characters long
- The first character is always capital and an alphabetical character
- The second and third characters are always digits
- All sub-questions must be subject to the same validation
Example acceptable inputs:
- A1
- B10
- C16
Rejected inputs:
- 1A
- A1A
- CC1
I've made a regular expression to match these:
Code:
/([A-Z]{1}\d{1,2})/g
A-Z{1} - 1 capital letter
\d{1,2} - 1 or 2 digits
I've tested that my inputs are being correctly matched using
regexr.com
however, when putting it into LimeSurvey, my condition is returning as FALSE.
Expression flags (Parameter after the last /) are often a source of trouble in LimeSurvey.
The Expression manager is fine with
regexMatch('/([A-Z]{1}\d{1,2})/', Q1_1)
but marks a faulty regex when using your valid term:
regexMatch('/([A-Z]{1}\d{1,2})/g', Q1_1)