Visual Studio 使用正则表达式查找和替换 html 标签之间的内容
Visual Studio Find and Replace content between html tags using regex
我想使用相当于:
\<FooterTemplate.+?\<\/FooterTemplate\>/gms
在 html/asp 标签及其内容的查找和替换正则表达式中 visual studio 2015。
上述正则表达式在 VS 中不起作用,但在 regex101.
中起作用
我最接近的 VS 语法是这样的:
\</*FooterTemplate[ ]*.*\>
但只匹配外部标签:
如何编辑上述正则表达式以在搜索时在标签之间包含内容?
在 VS 搜索和替换工具中,您可以使用 [\r\s\S]
字符 class 来匹配跨越多行的任何文本。
要匹配尽可能少的字符以获得有效匹配,您需要使用 *?
或 +?
惰性量词。
所以,您可以使用
<FooterTemplate[\r\s\S]+?</FooterTemplate>
我想使用相当于:
\<FooterTemplate.+?\<\/FooterTemplate\>/gms
在 html/asp 标签及其内容的查找和替换正则表达式中 visual studio 2015。
上述正则表达式在 VS 中不起作用,但在 regex101.
我最接近的 VS 语法是这样的:
\</*FooterTemplate[ ]*.*\>
但只匹配外部标签:
如何编辑上述正则表达式以在搜索时在标签之间包含内容?
在 VS 搜索和替换工具中,您可以使用 [\r\s\S]
字符 class 来匹配跨越多行的任何文本。
要匹配尽可能少的字符以获得有效匹配,您需要使用 *?
或 +?
惰性量词。
所以,您可以使用
<FooterTemplate[\r\s\S]+?</FooterTemplate>