Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

regex for content between and including the parenthees

Can someone help me with a regex that will catch the following:

  • has to be at the end of the string
  • remove all characters between ( and ) including the parentheses

It's going to me done in javascript.

here's what i have so far -

var title = $(this).find('title').text().replace(/\w+\s+\(.*?\)/, "");

It seems to be catching some chars outside of the parenthees though.

like image 633
steve Avatar asked Nov 14 '22 04:11

steve


1 Answers

This deals with matching between parens, and only at the of the string: \([^(]*\)\s*$. If the parens might be nested, you need a parser, not a regular expression.

like image 112
robert Avatar answered Dec 29 '22 15:12

robert