Reimplement 'separate' using regular expression