如何用方括号替换字符串前面和结尾的引号?

我正在尝试将引号替换为{}之类的括号。我需要为bibtex导入转换数据,该数据不能使用引号。看起来像这样:

@article{NASIR20159,title = "Fault-tolerant context development and requirement validation in ERP systems",journal = "Computer Standards & Interfaces",volume = "37",pages = "9 - 19",year = "2015",issn = "0920-5489",doi = "https://doi.org/10.1016/j.csi.2014.05.001",url = "http://www.sciencedirect.com/science/article/pii/S0920548914000695",author = "S. Zafar Nasir and Tariq Mahmood and M. Shahid Shaikh and Zubair A. Shaikh",keywords = "Context development,Requirement validation,Enterprise Resource Planning,Fault tolerance,Data Mining",}

整个文件包含大约2000条这样的记录,以及我删除的摘要。现在,我需要用方括号替换字符串前面和结尾的所有引号。最后应该看起来像这样:

@article{NASIR20159,title = {Fault-tolerant context development and requirement validation in ERP systems},journal = {Computer Standards & Interfaces},volume = {37},pages = {9 - 19},year = {2015},issn = {0920-5489},doi = {https://doi.org/10.1016/j.csi.2014.05.001},url = {http://www.sciencedirect.com/science/article/pii/S0920548914000695},author = {S. Zafar Nasir and Tariq Mahmood and M. Shahid Shaikh and Zubair A. Shaikh},keywords = {Context development,Data Mining},}

您知道我该怎么做吗?我尝试过notepad ++和多个替换表达式,但没有成功。

o0wuchen0o 回答:如何用方括号替换字符串前面和结尾的引号?

  • Ctrl + H
  • 查找内容:^.+?=\h*\K"(.+)"(?=,)
  • 替换为:{$1}
  • 检查 环绕
  • 检查 正则表达式
  • 取消检查 . matches newline
  • 全部替换

说明:

^           # beginning of line
  .+?       # 1 or more any character but newline,not greedy
  =         # equal sign
  \h*       # 0 or more horizontal spaces
  \K        # forget all we have seen until this position
  "         # double quote
  (.+)      # group 1,1 or more any character but newline
  "         # double quote
  (?=,)     # positive lookahead,make sure we have a comma after

屏幕截图(之前):

enter image description here

屏幕截图(之后):

enter image description here

本文链接:https://www.f2er.com/2751677.html

大家都在问