Reputation:
I can't understand what is wrong with the following code:
System.out.println("TEST:"+"/index/index/(\\d+)/".length());
Output: TEST:19 . But as I see there must be 20. Where is my mistake?
Upvotes: 0
Views: 444
Reputation: 40438
In java, \
is an escape character.
So: The \\
is actually a single \
.
And therefore that part of the string reads like this: (\d+)
, which as per regex definition means "1 or more digits" :)
Upvotes: 5