remove unused permute; use escapeRegExp
should only set default regex options for search strings
fix bug with no global flag