Gentoo Archives: gentoo-user

From: Michael Orlitzky <mjo@g.o>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] OT scripting - strip zero if between period and digit
Date: Tue, 22 Jan 2019 13:34:52
Message-Id: 548d7ef2-f07c-b70c-78dd-7dd35c781452@gentoo.org
In Reply to: Re: [gentoo-user] OT scripting - strip zero if between period and digit by David Haller
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.

Replies

Subject Author
Re: [gentoo-user] OT scripting - strip zero if between period and digit Adam Carter <adamcarter3@×××××.com>