Splitting string based on a given "pattern"

nicked it from @jostein_olsen