Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removeAt only removes first match #2

Open
DTayloe opened this issue Jun 9, 2024 · 0 comments
Open

removeAt only removes first match #2

DTayloe opened this issue Jun 9, 2024 · 0 comments

Comments

@DTayloe
Copy link

DTayloe commented Jun 9, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant