CS2121 lab exercise 1 - hint

If you looked at the hints for some of the earlier parts, you may have seen that I wrote about what to do if you want to use "[" or "]" or "-" or "^" inside "[ ]".

The problem is when we want to use characters that normally have a special meaning (metacharacters, like "*" or "+" or "|" or ".") to mean e.g. "recognise a * character" or "recognise a + character" etc.. The solution used by egrep is to quote the special characters e.g.:

\* \+ \| \.
so we also need to quote "\" to mean "recognise a \ character":
\\

Other programs that use metacharacters, like lex and bash, have similar quoting rules. lex and bash allow us both to use "\" as above and also allow us to use other quoting characters e.g.:
"*" "+" "|" "."
which I think is slightly easier to use and read.