Rewriting conversion to use regex