【发布时间】:2017-08-03 15:29:14
【问题描述】:
我有一个包含一些链接的 XML 文件
<SupportingDocs>
<LinkedFile>http://llcorp/ll/lljomet.dll/open/864606</LinkedFile>
<LinkedFile>http://llcorp/ll/lljomet.dll/open/1860632</LinkedFile>
<LinkedFile>%20http%3A%2F%2Fllenglish%2Fll%2Fll.exe%2Fopen%2F927515</LinkedFile>
<LinkedFile>%20http%3A%2F%2Fllenglish%2Fll%2Fll.exe%2Fopen%2F973783</LinkedFile>
</SupportingDocs>
我正在使用正则表达式 "\]+>(?:https?://|www.)[^\]+\[^\]+>"并使用 c# var matches = MyParser.Matches(FormXml);
但它匹配前两个链接,但不匹配编码的链接。
我们如何使用 RegEx 匹配 URL 编码的链接?
【问题讨论】:
-
您在 https 之后匹配两个斜杠。这些存在于前两个中,但没有出现在第二个中。可能还有其他问题,但这是我第一次看到。
标签: c# regex pattern-matching urlencode