I am using XSLT with regexp:match exslt function. The said function takes JavaScript Regex pattern. Therefore I am trying to match a set of numbers 1 thru 3 OR 5 thru 7 OR 9 thru 23.
Following is the regex pattern I’ve come up with:
(^[1-3]$|^[5-7]$|^[9-23]{1,2}$)
This regex does NOT match with any value at all. Following alternate pattern is good only to a little extent:
(^[1-3]$|^[5-7]$|^9$|^[10-23]{2}$)
While this matches with all other expected number values except 14 thru 19. Why is it so and how to make the Regex good. BTW, I am using http://www.regextester.com/ to test the pattern matching.
Thank you.
You are working with strings not numbers so 14 or 19 or 20 are strings of digits not the numbers.
so
[10-23]{2}will match 0-2, 1,3 or 0,1,2,3 two times. Notice the missing 4-9.