좋아, 쉬운 사람. ActiveReport의 RichTextBox를 사용하여 임의의 HTML 코드 비트를 표시합니다. ActiveReport 지원Regex를 사용하여 특정 HTML 태그 바꾸기
HTML 태그는 여기에서 찾을 수 있습니다 : http://www.datadynamics.com/Help/ARNET3/ar3conSupportedHtmlTagsInRichText.html
내가 원하는 무엇의 예는 텍스트 정렬을위한 지원 태그를 사용하기 위해 <p style=\"text-align:*</p>
에 의해 <div style="text-align:*</div>
의 일치를 대체합니다. 내 HTML 입력에 정확한 일치를 찾으려면 다음 정규식 표현을 발견했다
:
<div style=\"text-align:(.*?)</div>
그러나, 나는 내 교체 후 태그에 포함 된 이전 텍스트를 유지하는 방법을 찾을 수 없습니다. 어떤 단서? 나 아니면 Regex가 일반적으로 PITA인가? :)
private static readonly IDictionary<string, string> _replaceMap =
new Dictionary<string, string>
{
{"<div style=\"text-align:(.*?)</div>", "<p style=\"text-align:(.*?)</p>"}
};
public static string FormatHtml(string html)
{
foreach(var pair in _replaceMap)
{
html = Regex.Replace(html, pair.Key, pair.Value);
}
return html;
}
고마워요!
RegEx와 HTML은 일반적으로 잘 작동하지 않습니다. http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags –
@Nick Gotch 고맙습니다. 나는 다른 누군가가 선한 싸움에 맞서서 기쁘다. –