[GTALUG] Hardcore sed foo

Giles Orr gilesorr at gmail.com
Tue Nov 5 07:21:40 EST 2019


On Tue, 5 Nov 2019 at 06:42, Giles Orr <gilesorr at gmail.com> wrote:

> On Tue, 5 Nov 2019 at 01:47, William Park via talk <talk at gtalug.org>
> wrote:
>
>> 0 or 1 match is ?
>> Eg.  echo /aaa/.bbb//ccc/123 | sed 's,\(/\.\?[^/]\)[^/]*,\1,g'
>> --William
>>
>
> Nice - that works too.
>
> Jeez regex is a pain - it took three minutes of staring at that just to
> figure it out, even though I knew what we were both trying to achieve.
>

PS.  Yours works better: mine fails on the double slash '//' because it
insists on looking for a non-slash item right after it and so produces
'/a/.b///1' when it should have given me '/a/.b//c/1' as yours did.  It's
somewhat academic as in processing prompts the regex should never encounter
two slashes with nothing between them, but ... I prefer the more correct
answer.  Thanks.

-- 
Giles
https://www.gilesorr.com/
gilesorr at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://gtalug.org/pipermail/talk/attachments/20191105/f1fda516/attachment.html>


More information about the talk mailing list