1 |
On 1/21/19 9:55 PM, David Haller wrote: |
2 |
> |
3 |
> $ printf '0.1.2.3 01.2.3.4 1.2.3.0 1.2.000.3\n' | \ |
4 |
> sed 's/0*\([[:digit:]]\+\)/\1/g' |
5 |
> 0.1.2.3 1.2.3.4 1.2.3.0 1.2.0.3 |
6 |
> |
7 |
|
8 |
There are actually more than four examples that it needs to work on. And |
9 |
more to the point, this is going to destroy any other numbers it finds |
10 |
in the input. Phone numbers, zip codes, addresses, credit cards numbers, |
11 |
timestamps, etc. will all get clobbered. It takes like 10 lines of |
12 |
python to do this right; it's silly to invest a ton of effort trying to |
13 |
come up with a regex solution that accidentally works. |