The special characters that you need to take care are \,^, ., [, ], -, |, +, *, ?, {, }, $, ?! and ?=

If you are using these characters in your search string "str", then you have to escape them using '\'.

Just let me know if you need any more information regarding your error.