This is the solution: 1?[\s-]?\(?(\d{3})\)?[\s-]?\d{3}[\s-]?\d{4}
I don’t understand what the second backslash before the parentheses is for? 1? - to capture for one [\s-]? - to capture for dash or white space \(?(\d{3})\)? - I am asking about this backslash in the beginning to capture the area code.
When I remove it, the code didn’t work.
Will someone help me explain? I understand the rest of it.
it is to escape the parenthesis, so it is a literal parenthesis and not the opening parenthesis of a capture group
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.