Regularization takes a specific value?

for example, a url is

var url = "https://plugins.jetbrains.com/plugin/7316-stylus-support.html";

I want to get plugin/7316-stylus-support
.

Feb.27,2021

url.substring('https://plugins.jetbrains.com/'.length,url.lastIndexOf('.'))

Why should this be taken regularly?
in fact, you can use the location attribute in the page to extract the path directly, and then remove the following extension.


var url = 'https://plugins.jetbrains.com/plugin/7316-stylus-support.html';
console.log(url.match(/com\/(\S*).html/)[1])

/http[s]?:\/\/[^\/]+\/(.+)\.html/
Menu