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,970
  • 1
  • 31
  • 44
Tim Robinson
  • 53,480
  • 10
  • 121
  • 138
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
  • 99,844
  • 45
  • 235
  • 372