Gentoo Archives: gentoo-user

From: Grant Taylor <gtaylor@×××××××××××××××××××××.net>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] OT scripting - strip zero if between period and digit
Date: Tue, 22 Jan 2019 00:59:47
Message-Id: a24250ac-c20d-9da2-4105-3beee97d7117@spamtrap.tnetconsulting.net
In Reply to: Re: [gentoo-user] OT scripting - strip zero if between period and digit by Michael Orlitzky
1 On 1/21/19 5:02 PM, Michael Orlitzky wrote:
2 > You need a parser, not a regular expression.
3
4 The first thing that came to mind is splitting the values and passing
5 them through printf.
6
7 > (You can do it with a regex, but it's going to be one of those comical
8 > twelve-page-long things.)
9
10 I don't know about 12 pages. But, yes, a regular expression that takes
11 all the possible cases into account, especially as the four octet IP,
12 will be … complicated. A regular expression to work on an individual
13 octet might be less complicated.
14
15 You can play with REs fairly easily via sed.