Haskell version. Preprocesses string into Regex object