I a looking for a Regex to match a string which should:
- start with a digit
- 'in-between' have a permutation of exactly 7 digits and 2 hyphens, without 2 consecutive hyphens
- end with a sequence of digit, hyphen, digit
Match:
- 01-234-5678-9
- 01234-56-78-9
- 0123-4-5678-9
- 012-345-678-9
- 01-234567-8-9
- 01-234-5678-9
- 0-12345-678-9
- 0-123-45678-9
- 0-123-45678-9
- 01-23456-78-9
- 0-123456-78-9
- 0-1234567-8-9
No Match:
- 01-234-56789-0
- 01-234-567-8
- 01--2345678-9
- 01-2345678--9
- 0-1-23456789
- -01-2345678-9
For now, I could not quite figure out how to match the 2 'in-between' hyphens: ^\d\d{7}\d-\d$
EDIT: Thanks to the answers I had to this question, I was able to expand it to this other question regarding ISBN-10 and ISBN-13...