【发布时间】:2013-10-29 12:00:39
【问题描述】:
如何使用 replaceAll() 更改字符串的子字符串 例如使用正则表达式“1[a-z]+”(用“X”分割)和代码:
"this is an example 1one"
应该产生:
"this is an example 1Xone"
【问题讨论】:
标签: string replace expression substring
如何使用 replaceAll() 更改字符串的子字符串 例如使用正则表达式“1[a-z]+”(用“X”分割)和代码:
"this is an example 1one"
应该产生:
"this is an example 1Xone"
【问题讨论】:
标签: string replace expression substring
试试这个:
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);
}
}
【讨论】: