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
Here's a solt. that checks for no data
var someStr = 'abc'; // add 123 to string to see inverse var thenum = someStr.match(/\d+/); if (thenum != null ) { console.log(thenum[0]); } else { console.log('no number'); }