Saturday, 31 August 2013

capturing with parentheses - what went wrong?

capturing with parentheses - what went wrong?

415-555-1234
650-555-2345
(416)555-3456
202 555 4567
4035555678
1 416 555 9292
Good sirs: For my regex lessons, I'm trying to capture the area code of
the above numbers. Now I've got the expression below which matches all the
numbers, but my first pair of parentheses is not capturing anything.
1?\s?\(?(\d{3})\s?-?\)?(\d{3})\s?-?(\d{4})
Have I somehow converted them into a non-capturing group? How to fix?
RegexOne.com just ran off and left me alone on this one.

No comments:

Post a Comment