Sujet : Re: Globbing versus regular expressions
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.unix.shellDate : 21. Jul 2024, 22:29:31
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v7jujr$8pms$2@dont-email.me>
References : 1
User-Agent : Pan/0.158 (Avdiivka; )
On Sun, 21 Jul 2024 09:01:18 +0200, Axel Reichert wrote:
Since regexes are (at quick glance) a superset of globs, why not
consistently use the former for both file names and strings?
I would guess:
1) Historical reasons; I would say wildcards originated before regexes.
2) Issues with syntax: for example, dots mean “any character” in a regex,
while they occur quite commonly in filenames, and having to escape them
all the time would be a pain.
3) Simplicity. Wildcards are much more limited than regexes, but they
are convenient for a lot of common cases.
Also, regexes have evolved a lot over time. They were considered fairly
exotic at the time of the origin of tools like awk or sed, and also they
varied quite a lot in syntax and capabilities. I would credit the coming
of Perl with popularizing the idea in quite a powerful form--so powerful
that “Perl-Compatible Regular Expression” (“PCRE”) has become the closest,
I think to a de-facto standard for how regexes should work.