Using regex in validation conditions

Am trying to validating some identifier id to only accept only digits between 1 and 3. The validation seem not to be working as expected. When I key in 88888, the validation is not violated. Any assistance will be appreciated.

System.Text.RegularExpressions.Regex.IsMatch(self, @"\d{1,3}")

When you type in 88888 you have two matches:

Hence there is no error of validation. So Survey Solutions interprets your regex correctly, but I don’t see how the regex that you’ve written corresponds to your objective, please explain it.

Regex is a very advanced functionality, and I don’t see how it is warranted here. A simple function ConsistsOf() should be sufficient in this case.

I actually only want at most 3 digits. Not more than that

Using regular expression seems indeed like an overkill for this task.

If you want to achieve that the interviewer can enter values between 0 and 999 (at most ‘3 digits’) and your question is of type numeric you could simply use


In case it is a text question, have a look at the functionality of patterns.

Please provide more information in case your case deviates from the aforementioned.

As usual, an inaccurate description leads to a confusion

This means that you want:

  • “121213121” , “1”, “123”, “33333333” as valid
  • “21313421”, “0”, “88888” as invalid.

On the contrary

this means that you want:

  • “123”, “89”, “0”, “842”, “-76” as valid
  • “121213121” , “33333333” as invalid.

I am almost certain that neither is actually needed for your survey.

At most 3 digits” doesn’t explicitly require the number to be positive, though it is rather strange to have an ID which may take negative values. So @peter_brueck makes an additional assumption here.

Please, don’t make the interviewers to generate sequential IDs from the top of their heads when doing a listing, (if this is what you are doing). They will inevitably make mistakes.

Best, Sergiy