Reputation: 4223
I'm trying the following instruction and I don't understand the TRUE value returned :
SELECT '1' ~ '(0[1-9])|[10-15]' ;
?column?
boolean
----------
t
If I make it simplier again, I still don't understand the value returned :
SELECT '1' ~ '[10-15]' ;
?column?
boolean
----------
t
Thank you for helping !
Thomas
Upvotes: 0
Views: 49
Reputation: 434665
This regex:
[10-15]
doesn't mean what you think it means. The things inside a character class (i.e. [...]
) are individual characters, not strings. So that regex matches a '1'
, anything between '0'
and '1'
, or a '5'
; simplifying, we have [015]
. In particular, that regex does not match anything between '10'
and '15'
as you seem to think.
I think you're looking for:
(0[1-9])|(1[0-5])
You just need to factor out the '1'
in the second part of the alternation in the same way that you factored out the '0'
in the first part.
Upvotes: 4