css - What is the regex for php to get the href value in all stylesheet tags from HTML? -


what general way grab href tags using regex , preg_match_all href value given tag not in order.

example:

<link href="foo.css" rel="stylesheet" type="text/css"/> <link type="text/css" href="bar.css" rel="stylesheet"/> <link rel="stylesheet" type="text/css" href="bar1.css"/> <link type="text/css" href="bar2.css" rel="stylesheet"></link> <link href="path/foo.css" rel="stylesheet" type="text/css"/> 

should result in :

array( 'foo.css', 'bar.css', 'bar1.css', 'bar2.css', 'path/foo.css', ) 

the regex expression looking this, require bit further refinement:

<link\s+(?:[^>]*?\s+)?href="([^"]*)" 

testing against

<link href="foo.css" rel="stylesheet" type="text/css"/> 

the returned value is

<link href="foo.css" 

here's place test out expressions: http://regexpal.com/


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -