handlestring function now handles delimiters as regular expressions