So you want to recognize certain
patterns in a string and translate them to other patterns? This sounds like a job for java.util.regex !
First you will need to think about what distinguishes one of these patterns. How do
you, as a reader, recognize them? Once you understand this, you can write it as a "regular expresion". The java.util.regex API has tools for doing just this sort of transformation.