On Sun, 09 Jul 2017 17:31:24 PDT Chris Torek <torek(a)torek.net> wrote:
It would have
been nice had RE's been the standard way to glob
files, but, that said, when I mention .*\.c to people instead of
*.c they don't much like it.
Regular expressions are more powerful than glob, but much
harder to use correctly. People who have not had exposure
to them get them wrong all the time. The most common mistakes,
in my experience, are or include:
- Forgetting to quote ".": "pat.h" accidentally matches
file "patch"! This should read "pat\.h" (but see next
point).
- Forgetting to anchor expressions on left and/or right:
"x\.c" matches "x.cc". This should read "x\.c$" (or
even
"^x\.c$" or perhaps ".*/x\.c$").
Also note that . in regexp doesn't match \n, while ? and * in a
glob expression do. Unix filenames can not contain \0 and /
but everything else is allowed.