regex - How can I extract a number from a string in JavaScript?

preview_player
Показать описание
I have a string in JavaScript (e.g., #box2), and I just want the 2 from it.
I tried:
var thestring = $(this).attr('href');
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.
Рекомендации по теме
Комментарии
Автор

If AI has learnt how to generate Regex then we're surely out of jobs for humans.

calvinlucian
join shbcf.ru