1 |
Hello, |
2 |
|
3 |
On Wed, 23 Jan 2019, Adam Carter wrote: |
4 |
>> $ printf '0.1.2.3 01.2.3.4 1.2.3.0 1.2.000.3\n' | \ |
5 |
>> sed 's/0*\([[:digit:]]\+\)/\1/g' |
6 |
>> 0.1.2.3 1.2.3.4 1.2.3.0 1.2.0.3 |
7 |
> |
8 |
>So [[:digit:]] is another way of writing [0-9] and the + just means another |
9 |
>instance of the proceeding expression, right, so your and Francois |
10 |
>solutions are functionally the same, and all the following are the same |
11 |
>too, right? |
12 |
|
13 |
Not quite. |
14 |
|
15 |
[[:digit:]]+ == [0-9][0-9]* |
16 |
|
17 |
Not too, that [:digit:] respects locale. Don't know where locale |
18 |
applies though. Probably Devanagari or such. I just made myself to use |
19 |
classes rather than char-ranges. See man 7 regex for more classes. |
20 |
|
21 |
HTH, |
22 |
-dnh |
23 |
|
24 |
-- |
25 |
"UNIX was not designed to stop people from doing stupid things, because |
26 |
that would also stop them from doing clever things." -- Doug Gwyn |