How do I compare strings using regular expressions?

How do I compare strings using regular expressions?


There are a number of slightly different syntaxes for regular
expressions; most systems use at least two: the one recognised by
ed, sometimes known as `Basic Regular Expressions', and the one
recognised by egrep, `Extended Regular Expressions'. Perl has
it's own slightly different flavour, as does Emacs.



To support this multitude of formats, there is a corresponding multitude
of implementations. Systems will generally have regexp-matching
functions (usually regcomp() and regexec()) supplied, but
be wary; some systems have more than one implementation of these
functions available, with different interfaces. In addition, there are
many library implementations available. (It's common, BTW, for regexps
to be compiled to an internal form before use, on the assumption that
you may compare several separate strings against the same regexp.)



One library available for this is the `rx' library, available from
the GNU mirrors. This seems to be under active development, which may be
a good or a bad thing depending on your point of view :-)






Home FAQ