I'm continually amazed how useful regular expressions are in my daily coding. I'm still working on the MhtBuilder refactoring, and I needed a function to convert all URLs in a page of HTML from relative to absolute:
but there are potential performance issues in recompiling the regex on each postback
They could just embed the precompiled regex into their assembly, but at the framework level of the coding pyramid it probably makes more sense to hard-code it.
[… did you know that the ASP.NET page parser uses regular expressions? …]
And another trivium is that the ValidateRequest logic that looks for HTML and other “potentially dangerous” markup in the postback does NOT use regexes. It could – it’s a natural application – but there are potential performance issues in recompiling the regex on each postback.
I have a few details about that here, including the hypothetical regex that they would use:
Anyone got a regex that converts an absolute path into a relative path? I need to convert “http://domain.com/folder/images/myimage.gif” to just “images/myimage.gif”.
Sorry , I 4got to add this information.All the links are of the form:
"a href=“disable_javascript:mapWindow=x_window.open(’/something.htm’)”
I need to convert these relative urls to absolute ones. I know that i have to use the Replace() method.How do i go about it??
I went thru the code that is posted above and didnt understand this line:
“html = r.Replace(html, “${attrib}=${delim1}” _HtmlFile.UrlRoot “/${url}${delim2}”)”
Hi guys,
I have a regular expression proble, I have a huge html text and I want to convert all a hreftext/a to text where the link does not start with http://
In short I want only external links in my document and want to replace others with their respective texts.