So, some way or another (playing around), I found myself with a regex like \\d{1}{2}.
Logically, to me, it should mean:
(A digit exac
Scientific approach:
click on the patterns to see the example on regexplanet.com, and click on the green Java button.
"1", and doesn't match "12", so we know it isn't interpreted as (?:\d{1}){2}.{1} might be optimized away, lets try something more interesting:{3} is ignored.$2, captures the empty string.Great! So {1} is valid. We know Java expands * and + to {0,0x7FFFFFFF} and {1,0x7FFFFFFF}, so will * or + work? No:
Dangling meta character '+' near index 0
+
^
The validation must come before * and + are expanded.
I didn't find anything in the spec that explains that, it looks like a quantifier must come at least after a character, brackets, or parentheses.
Most of these patterns are considered invalid by other regex flavors, and for a good reason - they do not make sense.