String input = "Arline ate eight apples and one orange while Anita hadn't any";
String regex = "(?i)((^[aeiou])|(\\s+[aeiou]))\\w+?[aeiou]\\b"
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(input);
while (m.find())
System.out.println(m.group());输出:Arline
ate
one
orange
Anita这个正则 开始的时候(?i)什么意思哈,为什么开头没有i的也有输出?求分析
String regex = "(?i)((^[aeiou])|(\\s+[aeiou]))\\w+?[aeiou]\\b"
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(input);
while (m.find())
System.out.println(m.group());输出:Arline
ate
one
orange
Anita这个正则 开始的时候(?i)什么意思哈,为什么开头没有i的也有输出?求分析
默认情况下,不区分大小写的匹配假定仅匹配 US-ASCII 字符集中的字符。可以通过指定 UNICODE_CASE 标志连同此标志来启用 Unicode 感知的、不区分大小写的匹配。
但指定此标志可能对性能产生一些影响...