VB.NET Match string between parentheses (brackets)

  • Looking for a pattern for matching text between brackets. For example: "(this is) a (test)" should output

    "this is"

    Using Dim m As Match = Regex.Match(str, pattern, RegexOptions.Multiline)

    I have searched stackOverflow, Google and tried examples on RegExr and nothing seems to work for me.

    These work on RegExr but in not VB.NET

    "\(([^)(]++|(?R))+\)" - error nested quantifier

    "(?<=\<p\>)(.*?)(?=<\/p\>)" - quantifier following nothing

    Others will return: "this is) a (test" - matching far outer brackets

    PS I could also do with the same for


    it would be good to have them all in one place for anyone looking under vb.net


    Your regex is very complicated! This one will grab all text in between two () and match the inner text. Play with it here.