正则表达式中的 \z 和 \Z 之间有什么区别,何时以及如何使用它?
从 http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html:
\Z The end of the input but for the final terminator, if any
\z The end of the input
但这在实践中意味着什么呢?当我使用 \Z 或 \z 时,你能给我一个例子吗?
在我的测试中,我认为这将返回true并返回false。但实际上两者都返回 false。错误在哪里?"StackOverflow\n".matches("StackOverflow\\z")
"StackOverflow\n".matches("StackOverflow\\Z")