Backreference to a capturing group that match nothing is different from backreference to a capturing group that did not participate in the match at all.
Capturing group that match nothing
Here, b? is optional and matches nothing.
Thus, (b?) is successfully matched and capture nothing. o is matched with o and \1 successfully matches the nothing captured by the group.
Capturing group that didn't participate in the match at all
Here, (b) fails to match at all. Since, the whole group is optional the regex engine does proceed to match o.
The regex engine now arrives at \1 which references a group that did not participate in the match attempt at all.
Thus, the backreference fails to match at all.
You have a test string .
Your task is to write a regex which will match , with following condition(s):
consists of 8 digits.
may have "" separator such that string gets divided in parts, with each part having exactly two digits. (Eg. 12-34-56-78)
This is a regex only challenge. You are not required to write any code.
You only have to fill the regex pattern in the blank (_________).