Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse is saying there's an Illegal repetition in this regex

if(possTape.matches("{\\(\\d+,\"[^:=;@\"\\)\\(\\{\\}\\[\\]]+\"\\)(,\\(\\d+,\"[^:=;@\"\\)\\(\\{\\}\\[\\]]+\"\\))+}"))

But what does that mean? I've tested this regex on regexpal (with adjustments made so it works as Java) but I don't see where there is an illegal repetition?

like image 849
Chucky Avatar asked Mar 01 '12 23:03

Chucky


1 Answers

escape the curly brackets?

According to this answer:

The { and } are special in Java's regex dialect (and most other dialects for that matter): they are the opening and closing tokens for the repetition quantifier {n,m} where n and m are integers. Hence the error message: "Illegal repetition".

like image 114
Scott Weaver Avatar answered Sep 22 '22 03:09

Scott Weaver