Add split() variants that keep the delimiters to String and j.u.r.Pattern

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Fixed
    • Priority: P4
    • 21
    • Affects Version/s: 20
    • Component/s: core-libs
    • b22
    • generic
    • generic

      Issue JDK-8280101 requests that String.split should keep the delimiter for grouped regex. This is a non-negligible behaviorally incompatible change and would probably break much existing client code.

      A safer alternative is to add API points to both String and Pattern, like
      String.splitWithDelimiters(String regex, int limit);
      Pattern.splitWithDelimiters(CharSequence input, int limit);

      Adding this functionality outside the JDK is somehow more complicated than necessary, so it makes sense to add it in the JDK itself.

            Assignee:
            Raffaello Giulietti
            Reporter:
            Raffaello Giulietti
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: