2014-06-21 2 views
0

Regex.Match를 사용하여 무언가와 일치 시키려고했지만 이미 인용 부호가 있고 Regex.Match의 인용 부호를 취소합니다. 다른 스레드를 확인했지만 대답이 제대로 작동하지 않았습니다.인용문 인용문 (Regex Matching)

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>

+0

당신이 정말로 다른 스레드를 선택하면, 당신이 알고있는 것 (http://stackoverflow.com/questions/1732348/regex-match-open-tags- [정규식 구문 분석 HTML은 정말 나쁜 생각입니다] except-xhtml-self-contained-tags) html 파서를 사용하십시오. HtmlAgilityPack은 훌륭합니다. – spender

+0

나는 실제로 다른 스레드를 확인하고 HtmlAgilityPack 이외의 다른 것을 사용하는 것이 나에게 더 쉽다고 결정했다. 나는 시도했지만. 그냥 개인적인 취향. – Mohanad

답변

1

따옴표를 이스케이프 처리해야합니다. 문자열 리터럴의 경우 \" (예 : "My name is \"Bob\".")을 사용하십시오. 축 어적 문자열 리터럴의 경우 "" (예 : @"My name is ""Bob"".")을 사용하십시오. Strings (C# Programming Guide)을 참조하십시오.

Match divisionWinsLosses = Regex.Match(website, @"<span style=""font-size: 18px; color: #6C0; height: 28px; text-shadow: 0 0 1px #000;"">(.*?)</span>"); 
+0

감사합니다. – Mohanad