Title
The file name in front of the. jpg may be underlined by a numeric letter
A friend answered with
\w+\.jpg
, the effect can be achieved. Another way of thinking, to match the value behind a slash? How do you write regular expressions?
Reply content:
Title
The file name in front of the. jpg may be underlined by a numeric letter
Have a friend to answer with \w+\.jpg
, can achieve effect. Another way of thinking, to match the value behind a slash? How do you write regular expressions?
Regular:\w+\.jpg$
String functions:strrchr($str, '/')
If not, you can use BaseName ()
Is this hard? Why is it all so complicated?
var reg = /[^/]*$/
I think too much, let's not talk to me.
I think it's possible.
var regex = /(?:[^\/]*\/)(\w+\.jpg)/;var str = "Theme/Home/images/logo.jpg";regex.exec(str)//["images/logo.jpg", "logo.jpg"]
/(?:[^\/]*\/)(\w+\.jpg)/
, where the (?:)
grouping is not captured and (\w+\.jpg)
is a capturing group.
regex.exec(str)
, the first array element is the string that matches the whole, and the second element is the content that the first capturing group matches to.