I have raw HTML and I need to set all IMG src="http://foo".
This is the RegEx I have so far, and it seems to work. In my environment, it is safe to assume that tags are uppercase and attributes are lowercase. I am doing this in .Net, but I don't think that the platform really matters here. \s is any whitespace in the .Net RegEx engine.
Can anybody improve on it?
Regex.Replace(htmlText, "(<IMG[^>]*\\ssrc=\")([^\"]*)(\"[^>]*>)", "$1http://foo$3")