Regex to find <link rel="stylesheet" tag
I need to find the link tag using Regex. I have this line in my html file.
<link rel="stylesheet" href="<c:url value="/styles/folders/masterTree.css" />" type="text/css" media="screen, print" />
I need a regex expression to find this. This is not a homework. I ne开发者_如何学Goed this as part of my office requirement.
Thanks to all in advance.
Using regex to parse html can be problematic as most (x)html is not actual valid.
Because of all the edge cases you end up with it breaking before long.
You don't specify what language you are developing in but if you are working in .net I would suggest looking into using HtmlAgilityPack:
- http://runtingsproper.blogspot.com/2009/09/htmlagilitypack-article-series.html
You shouldn't. A real HTML parser is the only reliable way to parse HTML.
精彩评论