Replace your code using regular expressions.