作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
直接来自 this Java API:
public boolean requireEnd()
Returns true if more input could change a positive match into a negative one.
If this method returns true, and a match was found, then more input could cause the match to be lost. If this method returns false and a match was found, then more input might change the match but the match won't be lost. If a match was not found, then requireEnd has no meaning.
Returns: true iff more input could change a positive match into a negative one.
最佳答案
让我们以这个简单的例子为例:
public static void main(final String... args)
{
final Pattern p = Pattern.compile("cat$");
final Matcher m = p.matcher("I have a cat");
m.find(); // finds a match
System.out.println(m.requireEnd()); // prints true
}
"I have a catflap"
"cat$"
与
"cat"
然后
.requireEnd()
会返回
false
:使用上面的输入,
cat
仍然会被正则表达式引擎匹配。
关于java - 关于 requireEnd Matcher 方法的说明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17618812/
直接来自 this Java API: public boolean requireEnd() Returns true if more input could change a positive m
我是一名优秀的程序员,十分优秀!