我有一个字符串:
{
{ 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" },
}
如何在, "Some Text"
之前匹配每行的最后}
?
顺便说一句,这是Sublime Text,我正在尝试这样做。这些值不像我在这里有的那样一致,我有几百行要替换。
我尝试, ".*"
,但匹配, "Some Text's, "Some Text"
。
答案 0 :(得分:1)
我不使用Sublime Text,但如果它支持前瞻,那么, ".[^"]*"(?= })
应该可以解决问题。
答案 1 :(得分:1)
你可以通过几种方式解决这个问题。
选项#1
我们匹配第一组,然后捕获第二组,包括组\1
或$1
中的逗号
"[^"]*"(, "[^"]*")
请参阅live demo
选项#2
我们使用预先查找匹配的集合。
, "[^"]*"(?= \})
请参阅live demo
选项#3
我们可以匹配整个字符串,我们的匹配包含在捕获组\1
或$1
\{[\S\s]*?(,\s+"[^"]*")\s+\}
请参阅live demo
答案 2 :(得分:0)