replacing type of function will do...
not knowing much about API methods for parsers but i think string api can help
logic can be
if
String s.equals(123) then get the index of "123" that will give position in a string where '1' among "123" is stored so you can replcae that way
else,
check::
String replaceFirst(String regex, String replacement)
Replaces the first substring of this string that matches the given regular expression with the given replacement.
at String 5.0 API:
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html