NotAgain
NotAgain

Reputation: 1977

Regex to get data after last closing brace

I am looking to extract the data after the last closing brace. This is the test string:

RAID-622(00)02(88)845364758

My regex is:

\).*

What I have managed to get is: )02(88)845364758

But what I want is 845364758

Any tips?

Upvotes: 0

Views: 94

Answers (2)

Pranav C Balan
Pranav C Balan

Reputation: 115272

You can use following regex [^)]*$ to get string after the last ) and at the end

Regex explanation here

Regular expression visualization

Upvotes: 1

anubhava
anubhava

Reputation: 786091

You can search for greedy regex:

.*\)

and replace it by empty string.

RegEx Demo

.*\) will match longest string before ) due to greedy .*, hence matching up to last ) in your input text.

Upvotes: 0

Related Questions