How can i check for opening and closing brackets in regex


I have been trying to solve -

Now i have read and searched but could not find any regex where i can check if there is any opening bracket then only there can be a closing bracket, i have been stuck on this point for some time now , can any one guide me here … thanks …below is my code -

function telephoneCheck(str) {
  var test1 = /\d?\s?\(?\d{3}\-?\)?\s?\d{3}?-?\s?\d{4}/;
  return test1.test(str);

telephoneCheck("1 555)555-5555");

You could check for the bracketed and the non-bracketed part and use | to match either of them.

1 Like

@kevcomedia - thank you so much …do yo u have any channel for javascript ?

What do you mean by channel for javascript?

Like a youtube channel

No, sorry. I can’t imagine myself having a youtube channel :fearful:. Not with my awkward stuttering voice :sweat_smile:

I’m trying to write what I learn though, but I don’t have much written for now

1 Like

This was really helpful. Thank you!