javascript - Find specific static file in URL using js Regex -


how can find if url has file in structure using regex?

http://domain.com/file.xxx
http://domain.com/.../file.xxx

where file.xxx ( .css / .js / .jpg ) etc ?

something like:

var staticurl = url.match(//) // verify if matches 

we suppose url function parameter.

you this:

var regex = /\.(css|js|jpg)$/i; var staticurl = regex.test(url); 

that find url ending in .css, or .js, or .jpg, , ignore case sensitivity.


Comments