Skip to content

removeAt only removes first match #2

Description

@DTayloe

You can see in the source code that removeAt(int index) only removes the first match:

  /// remove the character in [index] of the given string.
  String removeAt(int index) {
    var selectStr = _mainStr[index];
    return _mainStr.replaceFirst('$selectStr', '');
  }

This implementation is wrong. The following code shows how this can appear:

//          01234567
var str1 = "12.34.56";
print(str1.stringUtils().removeAt(5));

The element at position 5 was not removed, instead the element at position 2 was.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions