Validate string in javascript with parenthesis

Posted by user2932856 on Stack Overflow See other posts from Stack Overflow or by user2932856
Published on 2013-10-29T15:47:01Z Indexed on 2013/10/29 15:53 UTC
Read the original article Hit count: 111

I just need to validate 2 strings in javascript.

One of them must contain only 0 or more open parenthesis ( .

The other must contain only 0 or more close parenthesis ) .

This means only those characters are allowed in each value.

After spending a lot of time trying to understand the regex, I can't find a way to achieve this. With the escape characters I make a mess of the regex function.

This is what I thought:

/\(*/

Could anyone help me?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about regex