Regex for getting text between the last brackets ()

javascript, match, regex

Solution

Try this

\(([^)]*)\)[^(]*$

See it here on regexr

var someText="don't extract(value_a) but extract(value_b)";
alert(someText.match(/\(([^)]*)\)[^(]*$/)[1]);

The part inside the brackets is stored in capture group 1, therefor you need to use `match()[1]` to access the result.

Problem

I want to extract the text between the last `()` using javascript For example ``` var someText="don't extract(value_a) but extract(value_b)"; alert(someText.match(regex)); ``` The result should be ``` value_b ``` Thanks for the help

Original source

Related problems