I have large text. I need to find an URL and replace the found text with another text.
Here is an example:
http://cdn.example.com/content/dev/images/some.png
http://cdn.example.com/content/qa/images/some.png
http://cdn.example.com/content/preprod/images/some.png
to
http://cdn.example.com/content/qa/images/some.png
http://cdn.example.com/content/preprod/images/some.png
http://cdn.example.com/content/live/images/some.png
I need to find url segment and just replace the found segment.
i have the following code:
Regex rxCdnReplace = new Regex(@"http://cdn.example.com/content/(\w+)/", RegexOptions.Multiline | RegexOptions.IgnoreCase);
rxCdnReplace.Replace(str,new MatchEvaluator(CdnRename.ReplaceEvaluator))
How can I do this with regex?
try this regex:
It returns the value between content/ and /images
E.g. for the link
http://cdn.example.com/content/dev/images/some.pngthe regex returns
devwhich you should replace withqa