Regex 在崇高的文本3中使用重新替换
在Sublime Text 3中安装RegReplace插件,以对文档进行若干更改。按照文档创建搜索和替换规则,但我提出了几个我无法找到解决方案的问题。 这些是创建的规则Regex 在崇高的文本3中使用重新替换,regex,sublimetext3,Regex,Sublimetext3,在Sublime Text 3中安装RegReplace插件,以对文档进行若干更改。按照文档创建搜索和替换规则,但我提出了几个我无法找到解决方案的问题。 这些是创建的规则 { "format": "3.0", "replacements": { "cambio_afiliacion": { "find": "\\affil{([0-9,]*)}", "replace": "<sup&g
{
"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
},
}
}
要编辑的文件案文如下:
\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}
\
Ivonne Narváez Zurita\affil{1}*
\第{introcción}节
并且应该得到这个结果
<a href="google.com">google.com</a>
Ivonne Narváez Zurita<sup>1</sup>*
<h3>Introducción</h3>
Ivonne Narváez Zurita1*
导言
我找不到错误的位置,该错误没有执行所有替换,并且没有以正确的方式执行它们,如我获得的
\
中的\href
中所示,因为模式是在设置中的JSON字符串中定义的,所以您必须记住正确定义转义<代码>\\a将与作为特殊正则表达式转义的\a
相同。如果需要文本\
,则必须转义\\\\a
。这是一个额外的间接层次。您必须考虑JSON字符串转义、和regex模式转义。这很烦人,但正是使用升华设置的方式
"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
},
“cambio_afiliacion”:
{
“查找”:“\\\\affil{([0-9,]*)}”,
“替换”:“\\1”,
“贪婪”:没错,
“贪婪的范围”:真
},
“cambio_区”:
{
“查找”:“\\\\section{(+?)}”,
“替换”:“\\1”,
“贪婪”:没错,
“贪婪的范围”:真
},
“cambio_href”:
{
“查找”:“\\\\href{(+++)}{(+++)}”,
“替换”:“,
“贪婪”:没错,
“贪婪的范围”:真
},
"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
},