-2

What is the difference between the JDK6 java.util.regex.Pattern's "Boundary matchers" '\z' and '\Z'?

Background: I was trying to read a UTF-8 encoded file's contents into a String. Came across this solution. I discovered that java.util.scanner.useDelimeter uses a java.util.regex.Pattern. The previously mentione solution proposes '\Z'.

Community
  • 1
  • 1
BiGYaN
  • 6,974
  • 5
  • 30
  • 43
  • 4
    Can you explain in detail what confused you after you had [read the documentation](http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html)? Your question reads very much as though you saw the confusing matcher characters and immediately posted on SO without any prior research. – Duncan Jones Oct 14 '13 at 08:53
  • Thanks for pointing out the duplicate question. Somehow this question did not turn up when I googled using '\Z' '\z' and java.util.regex.Pattern. – BiGYaN Oct 15 '13 at 05:19
  • @DuncanJones. My question was along the practical difference. On hindsight, it appears that I should have posted the code that I tried with. – BiGYaN Oct 15 '13 at 05:21

1 Answers1

1

According to http://docs.oracle.com/javase/1.5.0/docs/api/java/util/regex/Pattern.html, the difference is that:

\Z  The end of the input but for the final terminator, if any
\z  The end of the input
rcs
  • 6,713
  • 12
  • 53
  • 75