W
W
Wasya UK2018-08-25 11:08:02
JavaScript
Wasya UK, 2018-08-25 11:08:02

How to strip filename from url?

for example, I have a string: ".../frontpage.html"
after executing I get "frontpage" Is it possible to select the last word without .html using a regular expression ?
lodash.last(link.split('/')).split('.')[0];


Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Crimsons, 2018-08-25
@dmc1989

str.replace(/.+\/(.+)\.html$/,'$1');
Returns what is needed. I checked on a couple of examples, so if there are exceptions, I don't know about them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question