62,614
社区成员
发帖
与我相关
我的任务
分享
public class TestTry {
public static void main(String[] args) {
String a = "abcdef";
String regex = ".*";
String b = a.replaceAll(regex, "x");
System.out.println(b);
}
}
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class Test{
public static void main(String[] args){
String content = "abcdefg";
String regex = ".*";
Matcher matcher = Pattern.compile(regex).matcher(content);
while(matcher.find()){
System.out.println("'" + matcher.group(0) + "'");
}
}
}