java 怎么利用正则表达式从给定的字符串中取出匹配规则字符串

如题所述

String testString = "java怎么利用正则表达式从给定的字符串中取出匹配规则字符串";
Pattern pattern = Pattern.compile("\\w+");

Matcher matcher = pattern.matcher(testString);
while(matcher.find())
{
System.out.println(matcher.group());
}
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答