簡體   English   中英

C#引號(正則表達式匹配)

[英]C# Quotes in quotes (Regex Matching)

我正在嘗試使用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>");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM