As Adam said, : is not a metacharacter. However, an escaped non-alphanumeric character is equivalent to the character itself, which is why your regexp works both ways. Escaped alphanumerics, on the other hand, have special meanings (\s is whitespace, \t is tab, \1 is first regexp match, etc). | [reply] [d/l] |
No. The list of meta characters is (from programming perl):
\ | ( ) [ { ^ $ * + ? .
These are the only characters requiring a backslash in a regular expression. I'll add the delimiter / to that list, if its part of your string.
Disclaimer: Obviously, if you do something like m!!, and then want to find an exclamation mark, then you'll need to escape it. Also, under that circumstance, you won't need to escape a /
Update: athomason adds a good point, be sure to read the next post too. | [reply] [d/l] |