A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© kkopopo 中级黑马   /  2014-3-24 17:40  /  1457 人查看  /  3 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

本帖最后由 kkopopo 于 2014-3-24 19:37 编辑

Enter your regex: .*foo  // 贪婪量词
Enter input string to search: xfooxxxxxxfoo
I found the text "xfooxxxxxxfoo" starting at index 0 and ending at index 13.

Enter your regex: .*?foo  // 勉强量词
Enter input string to search: xfooxxxxxxfoo
I found the text "xfoo" starting at index 0 and ending at index 4.
I found the text "xxxxxxfoo" starting at index 4 and ending at index 13.

Enter your regex: .*+foo // 侵占量词
Enter input string to search: xfooxxxxxxfoo
No match found.

求解析为啥 最后一个侵占是匹配失败? 不应该有一个吗 ?  
侵占不是一次性的吗?  那么整体的字符串xfooxxxxxxfoo 不正好匹配.*+foo
我感觉这个地方我理解的是错误的

评分

参与人数 1技术分 +1 收起 理由
何伟超 + 1

查看全部评分

3 个回复

正序浏览
一楼说的对,这个侵占后面不能跟任何东西,跟了任何东西都不可能匹配
回复 使用道具 举报 1 0
我回帖有奖励不?
回复 使用道具 举报

回帖奖励 +1

研究了一下终于明白了这个侵占后面不能跟任何东西,跟了任何东西都不可能匹配
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马