Regex question

Hi all, I’ve made a form using the following regex:

regex(.,’^[0-9]{5}$’)
regex(.,’^[0-9]{4}$’)

This regex should allow a 0 (zero) to be entered into the form, but after trying I noticed that any sequence of digits that start with a zero are refused by the form now. How can I adapt the regex to solve the issue?

So what could the sample of your entry be like?

  • How long? i.e. the digit length
  • Should not be starting from 0. What could it start with?

Thank you for the super fast response!

For this regex regex(.,’^[0-9]{5}$’) I wanted to say: all digits between zero and 9 (including zero), maximum five digits. So for example: 01234 and 12345

For the second regex the same, but with 4 digits maximum

@Annika, the code seems OK. All you need to do is that you will need to make the question type to text and appearance to numbers. This should solve your issue. For details, please feel free to go through our support article Restricting Text Responses With Regular Expressions.

Thank you! This solved the issue, much appreciated.

1 Like