use regexp.escape instead oy my own method, fix edge case bug when query ends with a backslash