J
Jason Lillywhite
I have following string:
s = "B747-400, 8,357 miles, 561 mph, 4 Pratt & Whitney PW 4056
turbofans, 56,000 lbs."
I want to remove the comma only from the numbers (8,357 miles and 56,000
lbs) separating the thousands. I want the string to read as follows:
"B747-400, 8357 miles, 561 mph, 4 Pratt & Whitney PW 4056 turbofans,
56000 lbs."
I thought this following regex would do the trick because it
successfully isolated the right commas in rubular.com
s.gsub(/\d+(,)\d+/, "")
It turns out that my regex removes the entire number, not just the
comma.
Am I wrong in saying that my regex searches for 1 or more numbers
surrounding a comma and replaces just the comma with ""?
Thank you.
s = "B747-400, 8,357 miles, 561 mph, 4 Pratt & Whitney PW 4056
turbofans, 56,000 lbs."
I want to remove the comma only from the numbers (8,357 miles and 56,000
lbs) separating the thousands. I want the string to read as follows:
"B747-400, 8357 miles, 561 mph, 4 Pratt & Whitney PW 4056 turbofans,
56000 lbs."
I thought this following regex would do the trick because it
successfully isolated the right commas in rubular.com
s.gsub(/\d+(,)\d+/, "")
It turns out that my regex removes the entire number, not just the
comma.
Am I wrong in saying that my regex searches for 1 or more numbers
surrounding a comma and replaces just the comma with ""?
Thank you.