问题:
我想使用正则表达式匹配某个xml子字符串(请参阅下面的ex。A)。问题是我无法匹配xml字符串末尾的斜杠,因为它在Regex中是一个有意义的字符。我甚至试过在我的模型插入斜线前一个反斜杠逃脱斜线(见下面的代码),但仍然不能使它工作...如何匹配xml字符串末尾的斜线?
问题:
赫克我如何使.NET正则表达式在xml字符串的末尾匹配斜杠?需要你的一些代码忍者来帮助我。在此先感谢您的帮助,我的朋友。
的输入:
<SummarySection id="_470">
<Title>Statistics</Title>
<Para id="_331"> Note: Estimated new cases in the United States in 2010:<Reference refidx="1"/> </Para>
</SummarySection>
守则:
// ex A: Pattern need to match (<Reference refidx="1"/>)
string xnodeptn = @"(<Reference refidx=""[a-zA-Z0-9]""/>)";
Regex refregex = new Regex(xnodeptn, RegexOptions.Compiled | RegexOptions.IgnoreCase);
MatchCollection mymatches = refregex.Matches(xe.ToString());
foreach (Match mch in mymatches)
{
...
}
string xnodeptn = @"(<Reference refidx=""[a-zA-Z0-9]""\/>)";
请不要在您的标题中添加诸如“(.NET Regex)”之类的内容。我们在[so]上使用了标签。 –
嗯...这是一个很难我的朋友......也许这里有人真的很聪明可以回答它... – m0rtimer
提供示例输入。 –