Take a look at the api for String, namely the replaceAll() method. You can loop through each rule and use this method to do the replacement