Sublime Text 正则表达式搜索和替换
Sublime text regular expression search and replace
使用 Sublime Text 3,我有一个包含许多行的文本文件,如下所示:
{"Currency" : "Andorran Franc","Code" : "ADF","USD/1 Unit" : "0.1853","Units/1 USD" : "5.3967"}
{"Currency" : "Andorran Peseta","Code" : "ADP","USD/1 Unit" : "0.007306","Units/1 USD" : "136.8890"}
对于每一行,我想删除 "Currency" 字段及其值,以便这些行看起来像:
{"Code" : "ADF","USD/1 Unit" : "0.1853","Units/1 USD" : "5.3967"}
{"Code" : "ADP","USD/1 Unit" : "0.007306","Units/1 USD" : "136.8890"}
但我无法想出要应用的正则表达式。
使用下面的正则表达式,然后用空字符串替换匹配的字符。
"Currency"\s*:\s*"[^"]*",
或
"Currency"\s*:.*?,(?="[^"]*"\s*:)
"Currency"[^,]*,
通过 empty string
尝试 this.Replace。查看演示。
https://regex101.com/r/tX2bH4/13
如果格式固定了就可以用这种简单的方式完成
使用 Sublime Text 3,我有一个包含许多行的文本文件,如下所示:
{"Currency" : "Andorran Franc","Code" : "ADF","USD/1 Unit" : "0.1853","Units/1 USD" : "5.3967"}
{"Currency" : "Andorran Peseta","Code" : "ADP","USD/1 Unit" : "0.007306","Units/1 USD" : "136.8890"}
对于每一行,我想删除 "Currency" 字段及其值,以便这些行看起来像:
{"Code" : "ADF","USD/1 Unit" : "0.1853","Units/1 USD" : "5.3967"}
{"Code" : "ADP","USD/1 Unit" : "0.007306","Units/1 USD" : "136.8890"}
但我无法想出要应用的正则表达式。
使用下面的正则表达式,然后用空字符串替换匹配的字符。
"Currency"\s*:\s*"[^"]*",
或
"Currency"\s*:.*?,(?="[^"]*"\s*:)
"Currency"[^,]*,
通过 empty string
尝试 this.Replace。查看演示。
https://regex101.com/r/tX2bH4/13
如果格式固定了就可以用这种简单的方式完成