For example, I have this string:
222
What pattern I should use to get a count of "22" matches exactly 2 times?
222 -> (22)2 and 2(22)
So, for 2222 I would have 3 matches:
2222 -> (22)22 and 2(22)2 and 22(22)
Try 2{2}
. The number inside the braces is the number of repetitions of the token prior to the opening brace.