BASIC regular expressions...(BRE)
in a BRE...
* "plain" characters match themselves
* the following characters a BRE are special
ANYWHERE:
. * [ \
some characters in a BRE are special under
particular conditions:
^ is special at the beginning of a pattern
$ is special at the end of a pattern
the character that terminates a string/pattern
is special throughout the string/pattern
BUT what this character is depends on the context
* so, getting into the MEANINGS of these special characters
(or most of them...)
\ escapes the special meaning of a special character
(but the behavior of a backslash preceding a non-special
character in a BRE is undefined, and so should be avoided)
. matches any single non-null character
(sort of the equiv to pattern expansion's ?)
^ - a hat/caret at the beginning of the outermost
RE matches the BEGINNING of a line
(anywhere else it just matches itself)
$ - a dollar sign at the end of the outermost
RE matches the END of a line
(anywhere else it just matches itself)
* - the asterisk is DIFFERENT from when used in
filename expansion!
a single character followed followed by a *
matches 0 or more occurrences OF THAT CHARACTER
a* - 0 or more a's
H* - 0 or more H's
a pattern that matches a set of characters followed
by a * matches 0 or more characters FROM THAT SET
[moxie]* - matches 0 or more m's, o's, x's,
i's, e's, in ANY combination
* helpful tip: if you want 0 or more
of ANY character,
use .*
* [set] - a set of characters in square brackets
matches any SINGLE character from the
set (called a BRACKET EXPRESSION]
MOSTLY the same as for bracket expressions
in filename expansion,
EXCEPT... for a few things
ex: a ^ after the opening bracket
but before the set means match
any character NOT in that set
[^0-9] - should match any single non-digit