javascript - Grab Values between Slashes using Regex -


http://example.com/...../post/index/88/mike-hey-dddd

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

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -