I want to remove those parenthesis which are empty from expression in javascript regular expression. For e.g (() a and b) -> ( and b). It should also work for the case ( ( ( () ) )a and b) -> (a and b). Basicaly it should remove unnecessary parenthesis from expression. I am writng reguar expression
expression.replace(/(\s)/,'');
but this is not working. Can anyone help ?