J
JJ
I can get a set of matches of URL's by using a match expression that has a
named capture group in it, i.e.:
Regex reg_linkTags = new Regex("(?:.....long resular
expression......)(?<url>\\w+|\"[^\"]*\"|'[^']*')(??:\\s+\\w+\\s*=\\s*)(?:
......long regular expression......)", RegexOptions.IgnoreCase |
RegexOptions.Compiled | RegexOptions.Multiline);
MatchCollection tagMatches = reg_linkTags.Matches(myString);
Then get the url named capture group by:
for (int i = 0; i <= (tagMatches.Count - 1); i++)
{
CurrentUrl = tagMatches.Result("${url}");
BUT how do I _replace_ the url in the original string ('myString'). I can
match them , but I cannot seem to replace them. I tried using regex.replace,
but I don't think I can use this with either 'non capturing groups' (which I
wrap the named capture group 'url' in) or with named capture groups can I?
Thanks,
JJ
named capture group in it, i.e.:
Regex reg_linkTags = new Regex("(?:.....long resular
expression......)(?<url>\\w+|\"[^\"]*\"|'[^']*')(??:\\s+\\w+\\s*=\\s*)(?:
......long regular expression......)", RegexOptions.IgnoreCase |
RegexOptions.Compiled | RegexOptions.Multiline);
MatchCollection tagMatches = reg_linkTags.Matches(myString);
Then get the url named capture group by:
for (int i = 0; i <= (tagMatches.Count - 1); i++)
{
CurrentUrl = tagMatches.Result("${url}");
BUT how do I _replace_ the url in the original string ('myString'). I can
match them , but I cannot seem to replace them. I tried using regex.replace,
but I don't think I can use this with either 'non capturing groups' (which I
wrap the named capture group 'url' in) or with named capture groups can I?
Thanks,
JJ