I want to extract 8-digit numbers from a paragraph. It can contain a single optional hyphen anywhere between digits and MUST start with 6 or 7, so the following should match:
71234567
6-1234567
7-123-4567
61-23-45-67
7-1-2-3-4-5-6-7
...
I'd like to extract only the digits, so when matching 7-1-2-3-4-5-6-7, it returns only 71234567.
I tried to hardcode it like this:
[\b\D]([67]-?\d-?\d-?\d-?\d-?\d-?\d-?\d)[\b\D]
and then removing manually the hyphen later, but it doesn't work.