/*
*功能描述:已知:yi er san si wu liu qi ba jiu 分别对应123456789,
*对一段只含有这几种字符串的字符串进行转换,如:
*输入:yiersansan
*输出:1233
*/
import java.util.Scanner;
import java.util.Map;
import java.util.HashMap;
class Main12{
public static void main(String[] args) {
System.out.println(Replace("yierxxsansanss"));
}
public static String Replace(String source){
Map<Integer,String> map=new HashMap<Integer,String>();
map.put(new Integer(1),"yi");
map.put(new Integer(2),"er");
map.put(new Integer(3),"san");
if (source ==null) {
return null;
}
for(Map.Entry<Integer,String> mo:map.entrySet()){
String oldString=mo.getValue();
Integer in=mo.getKey();
String newString=String.valueOf(in);
while(source.indexOf(oldString)>=0){
source=source.replace(oldString,newString);
}
}
return source;
}
}