var regex = /\d+/g;
var string = "Any string you want!";
var matches = string.match(regex); // creates array from matches
if (matches){
// There is a digit in the string.
} else {
// No Digits found in the string.
}
const thestring = "1 fish 2 fish red fish blue fish";
const thenum = thestring.replace( /^\D+/g, ''); // replace all leading non-digits with nothing
console.log(thenum); //Output: 12