Doing text processing in AppleScript is a nightmare, and I imagine (from my very brief look at Automator) that Automator would likewise make a poor job of text processing.
This would be a simple one-line PERL script. PERL is king when it comes to text operations.