1

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

thanks

MHD
  • 21
  • 1

2 Answers2

4

You should try the HTML Agility Pack.

carla
  • 1,880
  • 1
  • 34
  • 41
Tim Robinson
  • 51,912
  • 9
  • 117
  • 136
0

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

Community
  • 1
  • 1
jgauffin
  • 97,689
  • 42
  • 231
  • 359