fixed error with lost character after function end, added handling for braces inside regexes