Reputation: 13
How to specify regular expressions with the repitition of ANTLR between 2 to infinity
Thanks
Upvotes: 1
Views: 51
Reputation: 95324
You can specify with most regexes the notion of 0 to infinity as:
(re)*
1 to infinity is usually expressed as:
(re)+
but in fact you can write this as equivalently as
(re)((re)*)
Using the same idea, 2 to infinity can be written as:
(re)((re)+)
Any "N to infinity" can be expressed as:
(re_1)(re_2)...(re_N) ((re)*)
where there are N (re) followed by re star.
Upvotes: 1