String.split documentation is misleading #46280
Labels
area-core-library
SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.
library-core
https://api.dart.dev/stable/2.13.2/dart-core/String/split.html states:
I don't understand the usage of "matches" in the above statement. The search string being matched is where splits should occur, but "empty matches ... are ignored" and the example seem to imply that it's talking about the resulting tokens, which is inconsistent verbiage.The
Matches: ^^ ^^
doesn't make sense to me. Is it supposed to be showing what's matched by the search pattern? If so, shouldn't it be pointing to justbb
? Or if it's supposed to be pointing to the resulting tokens, shouldn't it be pointing to the twoa
s?The code behaves as described only because of the regular expression used.
It is not generally true that empty matches are ignored.If we instead usedstring.split('b')
, it would result in['a', '', 'a']
, or if we usedstring.split('a')
, we'd get['', 'bb', '']
.The text was updated successfully, but these errors were encountered: