我正在尝试使用Regex.Match来匹配某些内容,但是它已经包含了引号,并且取消了Regex.Match的引号。我检查了其他线程,但他们的答案对我不起作用。
Match divisionWinsLosses = Regex.Match(website, @"<span style="font-size: 18px; color: #6C0; height: 28px; text-shadow: 0 0 1px #000;">(.*?)</span>");
以防万一。网站的HTML代码是这样的:<span style="font-size: 18px; color: #6C0; height: 28px; text-shadow: 0 0 1px #000;">[What I want is here]</span>
您需要转义报价。在字符串文字中,使用\"
(例如"My name is \"Bob\"."
)。在逐字字符串文字中,使用""
(例如@"My name is ""Bob""."
)。请参见字符串(C#编程指南)。
Match divisionWinsLosses = Regex.Match(website, @"<span style=""font-size: 18px; color: #6C0; height: 28px; text-shadow: 0 0 1px #000;"">(.*?)</span>");
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句