Oh hmm I definitely entered it as \t, since I copied and pasted my script, but I added the backslash in.
The closing bracket character is escaped, and the only one that needs to be (since $ for example cannot mean the end of a string in a character class.)
Also, not all non-alphanumeric characters should be encoded (even if that is an idea) since only these characters and alpha-num form a valid URI according to internet standards. Even more so, the characters -_.~ should not be encoded.