jugg1es
jugg1es

Reputation: 1600

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.

Upvotes: 0

Views: 61

Answers (2)

hwnd
hwnd

Reputation: 70722

You can use the following regex:

[^/]+\.css

Or use \w which matches word characters:

\w+\.css

Live Demo

Upvotes: 2

muhasturk
muhasturk

Reputation: 2634

If I were you I would use the following regex

[\w_\-]+\.css

Because the following inludes whitespace characters

[^/]+\.css

Upvotes: 1

Related Questions