Regex - How can I do this?

Here is the problem link:

I’m sure it’s possible to solve this in a one-liner, correct? I tried looking at the hints, but honestly, I don’t understand what I’m supposed to do with the booleans.

This is my regex:
\[1\s\-\(]*\d{3}[\s\-\)]*\d{3}[\s\-]*\d{4}\

This seems to match correct numbers, but also matches examples like telephoneCheck("(555)5(55?)-5555"). My question is this, is there a way to only match the ‘)’ when there is a ‘(’ three digits earlier?

Bro firstly start using // in ur regex in place of \ and u should give the or | in ur regex…talking about ur problem u can fix it by using the or| and ? operators at correct places…try doing it urself or else i will give the correct solution if u will stuck just ask it again!!

try looking at lookaheads and lookbehinds, they are useful with this kinds of patterns

for example: /ab/ this would match the string "ab"

but if you have /a(?=.{3}e)b/
this match "ab" but only if after the "a" there are three characters and then an “e”, so it matches strings of the like "ab..e" where the dot is any character (you can obviously use any pattern inside the parenthesis, it was just an example)

Thank you lol typo from copying over from regex101
p.s. don’t give me the correct solution.

Thanks for the suggestion! I’m going to look into that now.