I think using regex still the best (and the coolest) tricks...your only need 5-10 line code to solve this