I have been working on the US telephone number validator challenge and I have passed all the tests with my regex
Please could someone give me an explanation for the difference between ( ) and [ ] ?
For example, I don’t understand why it’s necessary to use
(1\s?)? in parentheses but
[\s\-]? in square brackets.
I know that parentheses are for groups and square brackets are for ranges but I don’t understand what this means in practical terms.
Any help appreciated!