还真都会,就我不会

悟空也烦恼 2011-04-01 08:51:00
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的也有输出?求分析
...全文
77 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
zsq_kaka1 2011-04-01
  • 打赏
  • 举报
回复
(?i)表示启用不区分大小写的匹配,
默认情况下,不区分大小写的匹配假定仅匹配 US-ASCII 字符集中的字符。可以通过指定 UNICODE_CASE 标志连同此标志来启用 Unicode 感知的、不区分大小写的匹配。
但指定此标志可能对性能产生一些影响...
WoodZhuo 2011-04-01
  • 打赏
  • 举报
回复
CASE_INSENSITIVE

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧