I have a "pre" which is getting newlines added before the content and after the content ie:
<pre>
My Content
</pre>
The above seems to be equivalent to 2 newlines before and 1 after.
I would like to parse my HTML string for all "pre" tags and to remove these before and after newlines.
I would use ASP.NET code to do the replacing:
Regex.replace(myHtmlString,@"Regex Pattern",String.Empty);
The result should be:
<pre>My Content</pre>
So what would the "Regex Pattern" look like please?
Thanks in advance.
EDIT
Answer so far:
strCleanXhtmlDoc = Regex.Replace(strCleanXhtmlDoc,@"<pre>[\r\n]*(.*?)[\r\n]*</pre>", "<pre>$1</pre>")
The replace bit is $1.
EDIT:
Strruggling to get the Regex to work with:
<pre style="color: #a11f98;font-family: calibri;font-size: 14pt;font-style: normal;font-weight: normal;">
L1
L11
L111
</pre>
Which does need matching, to produce:
<pre style="color: #a11f98;font-family: calibri;font-size: 14pt;font-style: normal;font-weight: normal;">L1
L11
L111</pre>