简体   繁体   中英

Extracting css file name using Regex

I want to get style.css from this string using RegEx

http://domain.net/jitwp/wp-content/themes/strappress/style.css?ver=3.1.1

So far, I've tried \\/(?:.(?!\\/)) but it gets /style.css?ver=3.1.1 . I'm not sure how to ignore the query string at the end or skip the forward slash.

You can use the following regex:

[^/]+\.css

Or use \\w which matches word characters:

\w+\.css

Live Demo

If I were you I would use the following regex

[\w_\-]+\.css

Because the following inludes whitespace characters

[^/]+\.css

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM