Using regex instead of manual string parsing