jQuery Data Type How to - Remove () parenthesis from string








Question

We would like to know how to remove () parenthesis from string.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
window.onload=function(){<!-- w w  w . j  a  v a 2s . c o m-->
String.prototype.rmbrackets = function() {
  return this.replace(/\(.*?\)/g, "");
};
document.writeln("this is a (test)test!".rmbrackets());
}
</script>
</head>
<body>
</body>
</html>

The code above is rendered as follows: