encode both str and regex to BINARY