Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regex CSS full path

I would like to regex the fullpath of the css, for example I have this:

<link rel="stylesheet" href="../assets/myCssFile.css"/>

I would like to regex: /assets/myCssFile.css

What I tried is this: /(?:href)=("|').*?([\w.]+\.(?:css))\1/gi

but this returns me this: href="../assets/myCssFile.css"

Can someone help me out with the regex.

BTW: It is an response text of an ajax request which returns me a string of the html page

like image 828
Sireini Avatar asked May 17 '26 00:05

Sireini


1 Answers

href=\"(.*\.css)"

This will return "../assets/myCssFile.css" in a capture group.

https://regex101.com/r/a44Axz/1

All it is doing is saying:

I am only interested in text within quotes that immediately follows an "href" and only if it is a ".css" file.

like image 139
Pytth Avatar answered May 19 '26 15:05

Pytth