Skip to content

Instantly share code, notes, and snippets.

@JeffreyZhao
Created August 5, 2009 08:31
Show Gist options
  • Save JeffreyZhao/162592 to your computer and use it in GitHub Desktop.
Save JeffreyZhao/162592 to your computer and use it in GitHub Desktop.
Convert inline <pre /> to <br />
static string DoPre(string content)
{
return Regex.Replace(content, @"(<pre[^>]*>)([\s\S]*?)(</pre>)", match =>
{
return
match.Groups[1].Value +
String.Join("<br />", match.Groups[2].Value.Split('\n').Select(p => p.Replace(" ", "&nbsp;").Trim()).ToArray()) +
match.Groups[3].Value;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment