Results 1 to 2 of 2

Thread: [RESOLVED] RegEx.Replace problem.

Threaded View

  1. #1

    Thread Starter
    Frenzied Member FishGuy's Avatar
    Join Date
    Mar 2005
    Location
    Bradford UK
    Posts
    1,708

    Resolved [RESOLVED] RegEx.Replace problem.

    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?

    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;
            }
    Will this even be possible or do I need to look at somehow going through the string and replacing each match individually?

    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());
                }
    Last edited by FishGuy; May 18th, 2011 at 05:05 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width