Hi there,
I am trying to replace text in my xsl file. I have to replace all the http and https. But I can leave any links that start with <a href>
Ie; http://www.google.com has to replaced. But < a href=”google.co m”>google.com</a> has to remain as it is.
I am using regex to find all the http(s) and a hrefs in the text. I am struck here.
My code is,
I am trying to use Regex.Replace to replace my https. But I am unable to write the evaluate function.
My regex.replace replaces all the values with a single value.
Can some on please correct my regex.repalce. thank you.
I am trying to replace text in my xsl file. I have to replace all the http and https. But I can leave any links that start with <a href>
Ie; http://www.google.com has to replaced. But < a href=”google.co m”>google.com</a> has to remain as it is.
I am using regex to find all the http(s) and a hrefs in the text. I am struck here.
My code is,
Code:
Dim href As New Regex("(<a.*?>.*?</a>)", RegexOptions.IgnoreCase) Dim hrefs As New Regex("http(s)?://([\w+?\.\w+])+([a-zA-Z0-9\~\!\@\#\$\%\^\&\*\(\)_\-\=\+\\\/\?\.\:\;\'\,]*)?", RegexOptions.IgnoreCase) Dim matchahref As MatchCollection = href.Matches(StrIn) Dim matches As MatchCollection = hrefs.Matches(StrIn) for each match in matches StrIn = Regex.Replace(StrIn, "(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])", _ String.Format("<a href=""{0}"">{0}</a>", match.ToString())) next
My regex.replace replaces all the values with a single value.
Can some on please correct my regex.repalce. thank you.