Separate two numbers by a dash (-)

1. What is the problem? Be very detailed.
In the "CAP" question, the enumerator must enter multiple numbers, I want those numbers to be separated by a dash (-).
For example: 34-35-45
2. What app or server are you using and on what device and operating system? Include version numbers.
XLSForm Online v2.3.3
3. What you have you tried to fix the problem?

4. What steps can we take to reproduce the problem?
I could change the question type, I don't know how the situation can be solved
5. Anything else we should know or have? If you have a test form or screenshots or logs, attach below.
Prueba_plantilla.xlsx (12.9 KB)

Hi @Fredy_Angarita
in this case you probably need to use regex. I don't know how that regex should look like because you didn't tell us enough about those numbers. Building such a regex it's important to know if you need one or x dashes, two numbers between, three or x.

1 Like

I tried to do it, but couldn't. Prueba_plantilla.xlsx (12.9 KB)
The enumerator can enter "n" numbers, the length of the numbers is "n", a dash to separate the numbers. Also, the numbers must be greater than 31.5.

Answer (repeat 1): 35.6
Answer (repeat 2): 553-45-666
Answer (repeat 3): 777-444.7
Answer (repeat 4): 68-59.8-454-56.9-88-444
Answer (repeat n): n-n ... n

The important thing is to separate the numbers with a hyphen.
The number of records entered is n, that is, it is not defined.
The length of the numbers is n, that is, it is not defined.
The numbers must be greater than 31.5, that is, decimals.

The following regex should fulfill the above requirements, for both (positive) integer and decimal numbers:


Basically, the [1-9][0-9]*(\.[0-9]+)? detects a number, and (-[1-9][0-9]*(\.[0-9]+)?)* detects zero or more subsequent numbers prefixed with a dash.

However, your final requirement - the numbers must be greater than 31.5 - is going to be extremely difficult to accomplish with a regex, since regexes don't actually convert strings to numbers or perform relational mathematical operations on them; they just scan raw text... It'll be messy, but strictly speaking you can come up with a regex that'll syntactically detect numbers 'greater than 31.5', which you can then just substitute into the above template.

Hope it helps.

Hi @Xiphware
After trying several times, it worked, thanks.
Now I have to solve the constraint of >=31.5

Hi @Xiphware
Sorry to ask again.
I tried creating the constraint > = 31.5 with regex, but it doesn't work for me.


31(,[5-9]{1}) = 31,5 - 31,9
32-9? = 32 - 39,9
[4-9]0-9? = 40 - 99,9
[1-9][0-9]0-9? = 100 - 999,9
(-31(,[5-9]{1})|-32-9?|-[4-9]0-9?|-[1-9][0-9]0-9?)* = "-" hyphen and "*" other numbers after the hyphen.

I think the problem is in "|".

Is there another way to do it?

try this:


Basically, first or'd alternative [1-9][0-9]{2,} checks for 100+, next alternative [4-9][0-9] checks for 40-99, next alternative 3[2-9] checks for 32-39, all of which may be followed by an optional (assumed single?) decimal place. And the final alternative 31\.[5-9] checks for 31.5 ... 31.9

Like I said, messy... :wink:


Thank you very much @Xiphware, it has served!
You're very kind.