Hi,
I have a database containing Page ojects with html content. A lot of the rows in the db contain this content
<p style="float: left; margin-right: 20px; height: 300px;">
<img src="...">More html ...
</p>
So I created a super simple regex replace:
foreach (var page in db.Pages)
{
string pattern = @"<p style=""float: left; margin-right: 20px;"">(.*)</p>/ms";
if( Regex.Match(page.Content, pattern).Success)
{
page.Content = Regex.Replace(page.Content, pattern, "<div class=\"contentimage\" >$1</div>");
}
}
// db.SubmitChanges();
Altough when I run the regex in a regex testing tool, it works. but in c# code it doesn't. Can anyone help me out please.
If anyone know how to do an update with the regex replace in sql, that would be fine to.
Regex isn't my strongest point (altough a great shame). But it is on my list of things to learn asap ;)