I have a string in JavaScript (e.g #box2) and I just want the 2 from it.
I tried:
var thestring = $(this).attr('href');
var thenum = thestring.replace( /(^.+)(\w\d+\w)(.+$)/i,'$2');
alert(thenum);
It still returns #box2 in the alert, how can I get it to work?
It needs to accommodate for any length number attached on the end.