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

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -