问题描述:

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 need 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.

相关阅读:
Top