wc1202
wc1202

Reputation: 5

Match all after nth occurrence of specified character

I have a localization file that I need to edit, but there are two thousand lines, and I'd rather not do this by hand.

Each line is formatted like this: "abc" = "123"; and I need to replace whatever is in place of 123.

What I want it to do is match everything after the third ".

I've tried multiple combinations like (?:[^"]*"){3}, and variations of ^[.^"]"*[^"]"*[^"]"* but they do not produce what I need.

So in this example:

"abc" = "123";
"def" = "456";
"ghi" = "789";

123";,456";, and789"; should be matched.

Upvotes: 0

Views: 2052

Answers (2)

neoneye
neoneye

Reputation: 52171

This will capture anything between the last quotes

" = "(.*)";$

Upvotes: 0

trincot
trincot

Reputation: 350127

I would propose this:

[^"]*(?=";)

This only matches the part within quotes, excluding (but requiring) the ending ";.

See demo on regex101

Upvotes: 1

Related Questions