String 更改字符串的子字符串
如何使用replaceAll()更改字符串的子字符串 例如,使用正则表达式“1[a-z]+”(用“X”拆分)和代码:String 更改字符串的子字符串,string,replace,expression,substring,String,Replace,Expression,Substring,如何使用replaceAll()更改字符串的子字符串 例如,使用正则表达式“1[a-z]+”(用“X”拆分)和代码: "this is an example 1one" 应产生: "this is an example 1Xone" 试试这个: class Test { public static void main(String[] args) { String str = "this is an example 1one"; str = str.replaceAll(
"this is an example 1one"
应产生:
"this is an example 1Xone"
试试这个:
class Test {
public static void main(String[] args) {
String str = "this is an example 1one";
str = str.replaceAll("1([a-z]+)", "1X$1");
System.out.println(str);
}
}