(spec str) String.split() should explain string quoting for literal instead of regex behavior

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Unresolved
    • Priority: P4
    • None
    • Affects Version/s: 6
    • Component/s: core-libs
    • Cause Known
    • generic
    • generic

      Bugs 5061438 and 6253831 show that users sometimes fail to notice that the argument to String.split is a regular expression, not just a plain String. They then expect e.g. "a|b".split("|") to return strings "a" and "b". In fact it returns strings "", "a", "|", and "b", because "|" is a regular expression meaning "empty string or empty string". It would be good to add some text to both String.split methods that points out this pitfall and suggests using Pattern.quote.
      ###@###.### 2005-04-13 12:26:48 GMT

            Assignee:
            Unassigned
            Reporter:
            Eamonn McManus
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: