The .replace() function I'm currently using is str.replace(/ *\([^)]*\) */g, ' ').replace(/ *\[[^)]* */g, ' ')
However, this doesn't works when there are nested parenthesis and brackets. For examples if str was (something something (something))
, the replace statements would return ')' instead of a blank string. Is there anyway to get rid of all content inside nested parentheses?