In my Google form I would like to authorize numbers and range of numbers like this:
1 to 9,
10 to 80,
90,
100
The separator can be , | ; or newline character, other examples
100
110 to 115
540
or
50 | 60 | 70 to 80 | 100
I was expecting this regEx to work (selecting Regular Expression > Matches > (to)|[0-9 \n|,;]*) but it failed.
Any idea ?
CodePudding user response:
You can use
^\d (?:(?:\s*(?:to|[\n|;,])\s*)\d )*\n*$
See the regex demo. Details:
^- start of a string\d- one or more digits(?:\s*(?:to|[|;,])\s*\d )*- zero or more occurrences of\s*(?:to|[\n|;,])\s*-toor|,;,,or newline enclosed with zero or more whitespaces\d- one or more digits
\n*- zero or more newlines$- end of string.
