求教一个正则表达式(replaceall())
String s1= "User ID:${id}name:${name} "
我想用replaceall()
将${id}变为001,${name}变为zhang
怎么写replaceall()的参数?
------解决方案--------------------String s1= "User ID:${id}name:${name} ";
System.out.println(s1.replaceAll( "\\$\\{id\\} ", "001 ").replaceAll( "\\$\\{name\\} ", "zhang "));
------解决方案--------------------String s1 = "User ID:${id}name:${name} ";
s1 = s1.replaceAll( "\\$\\{id\\} ", "001 ").replaceAll( "\\$\\{name\\} ", "zhang ");
System.out.println(s1);
------解决方案--------------------s1.replaceAll( "\\$\\{id\\} ", "001 ").replaceAll( "\\$\\{name\\} ", "zhang ")