I have a string which holds html, all the image tags have their src set as a value, I have half set up a function to get the value and look up in the database what the actual url should be.
I now need to replace the various values in the string, how do I pass the function the value that the regex replace is currently evaluating?
Will this even be possible or do I need to look at somehow going through the string and replacing each match individually?Code:public String replaceID_withImagesrcs(IRepository<Corp.Web.Model.Image> objImages, String Text) { String parsedtext; parsedtext = Text.Replace("complete=\"complete\"", ""); String t18 = @parsedtext; Corp.Web.Model.Image objImage; String p18 = @"(?<=img\s+src\=[\x27\x22])(?<Url>[^\x27\x22]*)(?=[\x27\x22])"; Regex.Replace(t18, p18, (objImage = objImages.FindById(Convert.ToInt64(?????????))).URLRefRegexOptions.Singleline); return t18; }
Code:foreach (Match match in Regex.Matches(t18, p18)) { Corp.Web.GSP.Model.Image objImage; objImage = objImages.FindById(Convert.ToInt64(match.Value)); String.Replace(match.Value, objImage.URLRef.ToString()); }





Reply With Quote