Can anybody elaborate the difference between “Char” and “String” at Java

Total Post:19


 1644  View(s)
Rate this:

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.

  1. Re: Can anybody elaborate the difference between '\Z' and '\z' in java.util.regex.Pattern?

    The difference is anchor \Z matches the empty string just before the newline, while \z matches empty string after the newline.

    A very simple example to understand this is:

    System.out.println("abc\n".matches("abc\\Z\\n"));   // true
    System.out.println("abc\n".matches("abc\\z\\n")); // false
    System.out.println("abc\n".matches("abc\\n\\z")); // true

      Modified On Apr-03-2018 04:25:31 AM


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.