Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在正则表达式模式中使用相同的变量。
string Pattern = "<li.*?class=\".*?item\".*?>.*?<a.*?href=\"(?<link>.*?)\">(?<a1>.*?)>(?<title>.*?)(a1)";
例如,如果"<span>"在 a1 中,在 title 变量之后"<span>"应该变成。
"<span>"
如果您需要引用以前捕获的组
利用
\index//where index is the group number
或者
\k<name>//where name is the name of the group
所以在你的情况下应该是\k<a1>
\k<a1>
正则表达式也不用于解析 HTML
使用htmlagilitypack