First question, how comfortable are you with regular expressions? My original assumption was that you are... but in reading it again, there were little in the post that warrant that.
... regardless, the Scanner class that you are using, and how you are using it (line by line), doesn't have direct replace capability. However, the line that is read in, is held in a
string, and does have regex replace capability. Additionally, if you are uncomfortable with regex, the String class also has search and replace capability, that doesn't require knowledge of regexes. Take a look at the Documentation for the String class for more details.
Henry