我试图编写一个( regex )来捕获关闭EViews字符串的双引号。在EViews中,字符串以双引号括起来,为了在字符串中包含实际的双引号,我们编写双引号:
myStr = "item1 item2 item3"
myStr2 = """item1"" ""item2"" ""item3"""字符串可以出现在行的任何位置,所以我不能通过使用行的开头和结尾来帮助我。
到目前为止,我得到的是:
((?<="")|(?<!"))(")(?!")也就是说,找到一个双引号,它前面有两个双引号或没有双引号,并且没有双引号。这捕获了结束双引号,但遗憾的是,也是开场白。
另外,我需要这样做的原因是,我正在处理一个描述崇高文本3的EViews语法的YAML文件。
strings:
- match: '"'
scope: punctuation.definition.string.begin.eviews
push: string
string:
- meta_scope: string.quoted.double.eviews
- match: '"' #((?<="")|(?<!"))(")(?!")
scope: punctuation.definition.string.end.eviews
pop: true发布于 2016-11-17 16:40:46
这个问题也许没有用最好的方式表述。最后,我找到了一个可能有点笨拙的解决方案,但效果很好:
strings:
- match: '"'
scope: punctuation.definition.string.begin.eviews
push: string
string:
- meta_scope: string.quoted.double.eviews
- match: '""'
- match: '"'
scope: punctuation.definition.string.end.eviews
pop: truehttps://stackoverflow.com/questions/40656616
复制相似问题