我想在正则表达式模式中使用相同的变量。
string Pattern = "<li.*?class=\".*?item\".*?>.*?<a.*?href=\"(?<link>.*?)\">(?<a1>.*?)>(?<title>.*?)(a1)";
例如,如果有"<span>"
在 a1 中,在标题变量之后 "<span>"
应该成为。
最佳答案
如果您需要引用以前捕获的组
使用
\index//where index is the group number
或
\k<name>//where name is the name of the group
所以在你的情况下它应该是 \k<a1>
此外正则表达式不用于解析 HTML
关于c# - 正则表达式模式中的相同变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13330871/