What are the differences between glob-style patterns and regular expressions?

Traditional glob wildcards support a very narrow set of metacharacters — * is “anything”, ? is an arbitrary single character; Bourne shell also supports [a-z123] for a single character out of a set of alternatives, and [!x-z789] any one except those listed.

Regex obviously is much richer, supporting repetitions, and (in ERE) alternation and specific numbers of repetitions. Perl-style regex further extends the formalism to the point where multiple books have been written, and more will be.

Basic regex is not altogether a lot more challenging to program than glob wildcards, and these days, a competent programmer would link to an existing library in either case, anyway.

Many simpler systems don’t want to burden their users with the complexity of learning regular expressions — even basic wildcards are a challenge to explain to your average sales guy^W^W person who isn’t a full-time computer user.

Leave a Comment