[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Does gawk manual mention how an empty regex should be handled?
From: |
Wolfgang Laun |
Subject: |
Re: Does gawk manual mention how an empty regex should be handled? |
Date: |
Wed, 31 Mar 2021 18:37:46 +0200 |
With any of the languages supporting pattern matching I've never read an
explicit documentation of this behaviour, but it seems kind of logical that
when /xxx...x/ matches "xxx...x" for any length n, that this also should
hold for length 0 (but forgive me, I'm a mathematician ;-) )
-W
On Wed, 31 Mar 2021 at 18:26, Arkadiusz Drabczyk <arkadiusz@drabczyk.org>
wrote:
> TIL that empty regex matches any string:
>
> $ awk 'BEGIN { print "abc" ~ "" }'
> 1
> $ awk 'BEGIN { print "abc" ~ // }'
> 1
>
> It can also be reproduced with mawk, Busybox awk and FreeBSD
> awk. However, I wasn't able to find an explanation of that behavior in
> the gawk manual. Is it actually documented somewhere?
>
> --
> Arkadiusz Drabczyk <arkadiusz@drabczyk.org>
>
>
--
Wolfgang Laun