I'm using grep
on TextWrangler to find strings of this type:
4,600.00
My regex command is the following:
\d.\d{3}.\d{2}
which seems to find the strings correctly. I would like to replace the string 4,600.00
with 4600.00
as I wish to save the data in a .csv
file. How do I remove the comma from each number that I find?
Search: (\d{1,3}),(\d{1,3})\.(\d{1,2})
Replace: \1\2.\3
Works in TextWrangler.
awk oneliner:
awk --re-interval '{x=gensub(/([0-9]{1,3}),([0-9]{3}\.[0-9]{2})/,"\\1\\2","g");print x}' file
test:
kent$ awk --version|head -1
GNU Awk 3.1.6
kent$ echo "foo,bar,blah,46,000.00,some,more"|awk --re-interval '{x=gensub(/([0-9]{1,3}),([0-9]{3}\.[0-9]{2})/,"\\1\\2","g");print x}'
foo,bar,blah,46000.00,some,more
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With