【发布时间】:2019-02-05 15:34:10
【问题描述】:
在 Sublime Text 3 中安装 RegReplace 插件以对文档进行多项更改。按照文档创建搜索和替换规则,但我提出了几个我找不到解决方案的问题。 这些是创建的规则。
{
"format": "3.0",
"replacements":
{
"cambio_afiliacion":
{
"find": "\\affil{([0-9,]*)}",
"replace": "<sup>\\1</sup>",
"greedy": true,
"greedy_scope": true
},
"cambio_section":
{
"find": "\\section{(.+?)}",
"replace": "<h3>\\1</h3>",
"greedy": true,
"greedy_scope": true
},
"cambio_href":
{
"find": "\\href{(.+?)}{(.+?)}",
"replace": "<a href=\"\\1\">\\2</a>",
"greedy": true,
"greedy_scope": true
},
}
}
这是你创建的在 Default.sublime-keymap 中运行它的快捷方式
{
"keys": ["ctrl+alt+j"],
"command": "reg_replace",
"args": {
"replacements": [
"cambio_afiliacion",
"cambio_href",
"cambio_section",
],
"find_only":false,
}
},
要编辑的文档文本如下
\href{google.com}{google.com}
Ivonne Narváez Zurita\affil{1}*
\section{Introducción}
当您执行快捷方式时,您只能以这种方式进行更改
\<a href="google.com">google.com</a>
Ivonne Narváez Zurita\affil{1}*
\section{Introducción}
应该得到这个结果
<a href="google.com">google.com</a>
Ivonne Narváez Zurita<sup>1</sup>*
<h3>Introducción</h3>
我找不到错误可能出在哪里,它没有执行所有替换,也没有以正确的方式执行它们,如我得到\<a> 的\href 所示。
【问题讨论】:
标签: regex sublimetext3