Reputation: 2009
I have a string like:
{
{ SomeTextNoQuotes, "Some Text's", "Some Text" },
{ SomeTextNoQuotes, "Some Text's", "Some Text" },
{ SomeTextNoQuotes, "Some Text's", "Some Text" },
{ SomeTextNoQuotes, "Some Text's", "Some Text" },
{ SomeTextNoQuotes, "Some Text's", "Some Text" },
}
How can I match the last , "Some Text"
of each row, just before the }
?
By the way, this is in Sublime Text that I'm trying to do it. The values are not consistent like I have them here, and I have a few hundred lines to replace on.
I tried , ".*"
but that matches , "Some Text's, "Some Text"
.
Upvotes: 0
Views: 101
Reputation: 70732
A few ways you could go about this.
Option #1
we match the first set and then capture the second including the comma in group \1
or $1
"[^"]*"(, "[^"]*")
See live demo
Option #2
we use a look ahead to find that matched set.
, "[^"]*"(?= \})
See live demo
Option #3
we can match the whole string and our match is included in capture group \1
or $1
\{[\S\s]*?(,\s+"[^"]*")\s+\}
See live demo
Upvotes: 1
Reputation: 53545
The following should work (using lookahead):
("Some Text")(?= \}\,)
The captured text will be found in the first matched group
Link to Fiddle
Upvotes: 0
Reputation: 198476
I don't use Sublime Text, but if it supports lookaheads, , ".[^"]*"(?= })
should do the trick.
Upvotes: 1