I'm looking for a javascript replace regex that will strip out everything but the first number in a string. (The last will also work as well, see my test cases below)
Given the following:
P1, PROTECTED 1
or
P3, PROTECTED 3
or
P10, PROTECTED 10
I need 1,3, or 10
I need to only return the first or last number. It'll be between 1 and 10. They're the same.
var foo = 'P10, PROTECTED 10';
foo.replace(/(\d+)/,'');
strips out the first number...I need the exact opposite