21
You want ...
if (stringYouHave.match(/^string:([0-9]+)$/)) {
// do something
}
This includes:
^ beginning of the stringstring: the literal "string:" you mentioned(.....) This subexpression, which you can refer to later if you need to know which number is in the string (though in this particular case, you could also just replace 'string:' with '')[0-9] a character between 0 and 9 (i.e., a digit)+ Must have at least one "of those" (i.e., digits mentioned above), but can have any number$ end of the string