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

Winapi c++: DialogBox hangs when breaking a loop -

vb.net - Font adding using PDFsharp -

javascript - jQuery iScroll clickable list elements while retaining scroll? -