javascript - Grab Values between Slashes using Regex -
i need grab ##
index/##/
"##" denotes numeric value.
i'm planning run regex javascript.
you can use \/
escape slashes want use in regular expressions:
so result be:
var input = "http://example.com/...../post/index/88/mike-hey-dddd"; var match = input.match(/\/index\/(\d+)/i); // make sure validate result, might not // match given alternative url. var number = match ? match[1] : false; alert(number);
Comments
Post a Comment