MHD
MHD

Reputation: 21

Parse HTML Document?

How i can replace image's source , html text saved in database ?

thanks

Upvotes: 1

Views: 388

Answers (2)

Tim Robinson
Tim Robinson

Reputation: 54764

You should try the HTML Agility Pack.

Upvotes: 4

jgauffin
jgauffin

Reputation: 101176

http://social.msdn.microsoft.com/Forums/en-US/regexp/thread/37f46a25-113c-420d-aab8-eea98d341189

string s = "<img src='1.jpg'><img src='2.jpg'><img src='3.jpg'><img src='4.jpg'>";
string pattern = @"<img\s+src\s*=\s*["']([^"']+)["']\s*/*>";
string output = string.Empty;
output = Regex.Replace(s, pattern, "[Image: $1]");

Regex to get src value from an img tag

Upvotes: 0

Related Questions