Regexp to match text between the last brackets in a string

I'm bit stuck. I'm looking for the correct regexp (for action) to find text between ( and ) that occur as last.

Right now I have:
$regexp(%title%,'^(.+?)\((.+?)\)$','$2')

But this does not give the correct result if the title string is: "Some song (feat. someone else) (Mixname)".
The correct result should be in this case: "Mixname".

The first match group is marked as non-greedy, trying to match as little as possible. You want the opposite, so

^(.+)\((.+?)\)$

should work.

1 Like

Thanks, that was it!

Can't turn my brain on for regexp anymore :roll_eyes: even tho I used to be writing them on daily basis decade ago. It all just looks like hieroglyphs to me, even tho I might have written them myself.

1 Like

I always recommend https://regex101.com for testing regular expressions — it even gives a short explanation of the different components, so it might help at re-understanding something that was once obvious.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.