Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8333782

Improve description of \b matcher in j.u.r.Pattern

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 24
    • core-libs
    • None
    • behavioral
    • minimal
    • This is just a documentation improvement, so there's no compatibility risk.
    • Java API
    • SE

      Summary

      The description of the \b boundary matcher in the Javadoc of j.u.r.Pattern is inaccurate. It needs to be improved.

      Problem

      The description of the \b boundary matcher in the Javadoc of j.u.r.Pattern is inaccurate. It is expressed in terms of another, rather complex regular expression pattern that fails to capture the intended behavior at the boundaries of the input.

      Solution

      Rather than using an even more complex regular expression pattern to describe what \b means, the description proposed here is just simple narrative. This better matches the overall descriptive style of the documentation.

      Specification

      @@ -251,8 +251,9 @@
        * <tr><th style="vertical-align:top; font-weight:normal" id="end_line">{@code $}</th>
        *     <td headers="matches bounds end_line">The end of a line</td></tr>
        * <tr><th style="vertical-align:top; font-weight:normal" id="word_boundary">{@code \b}</th>
      - *     <td headers="matches bounds word_boundary">A word boundary: {@code (?:(?<=\w)(?=\W)|(?<=
      \W)(?=\w))} (the location
      - *     where a non-word character abuts a word character)</td></tr>
      + *     <td headers="matches bounds word_boundary">A word boundary:
      + *     at the beginning or at the end of a line if a word character ({@code \w}) appears there;
      + *     or between a word ({@code \w}) and a non-word character ({@code \W}), in either order.</
      td></tr>
        * <tr><th style="vertical-align:top; font-weight:normal" id="grapheme_cluster_boundary">{@code
       \b{g}}</th>
        *     <td headers="matches bounds grapheme_cluster_boundary">A Unicode extended grapheme clust
      er boundary</td></tr>
        * <tr><th style="vertical-align:top; font-weight:normal" id="non_word_boundary">{@code \B}</th
      >

            rgiulietti Raffaello Giulietti
            webbuggrp Webbug Group
            Stuart Marks
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: