This deals with the general problem of extracting a signed number from a string that also contains hyphens.
Can someone please come up with the regex for the following:
"item205" => 205
"item-25 => -25
"item-name-25" => -25
Basically, we want to extract the number to the end of the string, including the sign, while ignoring hyphens elsewhere.
The following works for the first two but returns "-name-25" for the last:
var sampleString = "item-name-25";
sampleString.replace(/^(\d*)[^\-^0-9]*/, "")
Thanks!