I have a string in JavaScript like #box2 and I just want the 2 from it.
#box2
2
I tried:
var thestring = $(this).attr(\'href\'); var
For a string such as #box2, this should work:
var thenum = thestring.replace(/^.*?(\d+).*/,'$1');
jsFiddle: