1 |
On Wed, Jan 23, 2019 at 12:34 AM Michael Orlitzky <mjo@g.o> wrote: |
2 |
|
3 |
> On 1/21/19 9:55 PM, David Haller wrote: |
4 |
> > |
5 |
> > $ printf '0.1.2.3 01.2.3.4 1.2.3.0 1.2.000.3\n' | \ |
6 |
> > sed 's/0*\([[:digit:]]\+\)/\1/g' |
7 |
> > 0.1.2.3 1.2.3.4 1.2.3.0 1.2.0.3 |
8 |
> > |
9 |
> |
10 |
> There are actually more than four examples that it needs to work on. And |
11 |
> more to the point, this is going to destroy any other numbers it finds |
12 |
> in the input. Phone numbers, zip codes, addresses, credit cards numbers, |
13 |
> timestamps, etc. will all get clobbered. It takes like 10 lines of |
14 |
> python to do this right; it's silly to invest a ton of effort trying to |
15 |
> come up with a regex solution that accidentally works. |
16 |
> |
17 |
> |
18 |
Thanks Michael. The input data is constrained in ways I didnt list, so it |
19 |
might be possible to get away with a regex, but I appreciate you |
20 |
highlighting the risk of what sounds like a brittle approach. |
21 |
|
22 |
I am hopeful that one day learning python will make it to the top of my |
23 |
priority list. |