Вход

Просмотр полной версии : attr('href').match


rustoke
25.09.2015, 11:50
Есть ссылка
http://domain.ru/news/v-2015-godu-bla-bla-bla-upal-68693.html
Как мне выдернуть news и 68693 ?

рони
25.09.2015, 11:58
rustoke,
var href = "http://domain.ru/news/v-2015-godu-bla-bla-bla-upal-68693.html"
alert(href.match(/\d+(?=\.html)/));

ksa
25.09.2015, 15:27
Как мне выдернуть news
Как вариант...
var href = "http://domain.ru/news/v-2015-godu-bla-bla-bla-upal-68693.html";
alert(href.split('/')[3]);