Is it possible:
U.S. Patent 6,570,557
extract 3 groups:
So far I have received:
(US)(\s{1}Patent\s{1})(\d{1},\d{3},\d{3})
and tried to (?!,)get rid of the commas, then I really get rid of the whole number.
(?!,)
Try:
var input = 'US Patent 6,570,557', matches = input.match(/^(\w+) (\w+) ([\d,]+)/), code = matches[1], name = matches[2], numb = matches[3].replace(/,/g,'');
Instead of using a regular expression, you can do this with two simple functions:
var str = "US Patent 6,570,557"; // Your input var array = str.split(" "); // Separating each word array[2] = array[2].replace(",", ""); // Removing commas return array; // The output
It should also be faster.
, , .
String.replace.
String.replace
:
(US)(\s{1}Patent\s{1})(\d{1}),(\d{3}),(\d{3})
3