JSFiddle - React, Tailwind, and code Playground

JavaScript

var thestring = '#box2';
var thenum = thestring.replace(/^.*(\d+).*$/i,'$1');
alert(thenum);