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

replaceAll() method instead of the replace() #494

Closed
wants to merge 1 commit into from

Conversation

shivam-sharma7
Copy link
Member

Describe your changes

The replace() method only replaces the first occurrence of a pattern in a string, while the replaceAll() method replaces all occurrences of the pattern.

Fixes Issue

Check List (Check all the applicable boxes)

  • My code follows the code style of this project.
  • My change requires changes to the documentation.
  • I have updated the documentation accordingly.
  • All new and existing tests passed.

Copy link
Member

@gsmet gsmet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not true.

See https://www.baeldung.com/string/replace .

replaceAll uses a regexp and should generally be avoided.

@gsmet gsmet closed this Aug 29, 2023
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

Successfully merging this pull request may close these issues.

2 participants