-5

Need an regex patter to identify an number input with space delimiter, and the number range should be from 1 to 11.

e.g. It should detect following

1 2 3
1 11 4 5 6
1 4 3 9
11 4 5

e.g It should fail in detecting

12 2 3 
1 34 5555
23 3445 566 676544
dds 434 fv 434
dssd s ds sd 

I came up with

^([0]?\d|1[0-1])(([, ]([0]?\d|1[0-1]))*)$ 

But this also detect when I provide

1 0 6 7

This is not an duplicate question, and I have explained it well enough. Please read question properly and if still someone thinks it's an duplicate question then tell me why it's a duplicate one instead of just marking an duplicate.

anand
  • 392
  • 3
  • 8

1 Answers1

0

(?:([1-9][01]?)\s+)+ should do it.

Explanation:

(?: non capturing group

([1-9][01] two digits, first between 1 and 9, second optional

)\s+) spaces

)+ repeat the whole

xyz
  • 3,349
  • 1
  • 23
  • 29