The behavior with {,2}
is not expected, it is a bug. If you have a look at the TRE source code, tre_parse_bound
method, you will see that the min
variable value is set to -1
before the engine tries to initialize the minimum bound. It seems that the number of "repeats" in case the minimum value is missing in the quantifier is the number of maximum value + 1
(as if the repeat number equals max - min = max - (-1) = max+1
).
So, a{,}
matches one occurrence of a
. Same as a{, }
or a{ , }
. See R demo, only abc
is matched with ab{,}c
:
grepl("ab{,}c", c("ac", "abc", "abbc", "abbbc", "abbbbc"))
grepl("ab{, }c", c("ac", "abc", "abbc", "abbbc", "abbbbc"))
grepl("ab{ , }c", c("ac", "abc", "abbc", "abbbc", "abbbbc"))
## => [1] FALSE TRUE FALSE FALSE FALSE
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…