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

Added string.replace() and .replaceAll() #698

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

xiboon
Copy link

@xiboon xiboon commented Jul 3, 2024

finishes 1 task off of #683

@xiboon
Copy link
Author

xiboon commented Jul 3, 2024

@microsoft-github-policy-service agree

Copy link
Member

@pelikhan pelikhan left a comment

Choose a reason for hiding this comment

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

Could you add a test with replacing a string with multiple characters?

@xiboon
Copy link
Author

xiboon commented Jul 3, 2024

Could you add a test with replacing a string with multiple characters?

Added, also found a bug where replaceAll could loop infinitely so fixed that as well.

@pelikhan
Copy link
Member

pelikhan commented Jul 3, 2024

what if searchvalue equals replace value?

@xiboon
Copy link
Author

xiboon commented Jul 3, 2024

i believe it shouldn't be an issue, that was part of the bug with replaceAll because if replaceValue contained searchValue it would just match against it forever.
Now, after replacing a match it only searches for the index after the position of the replacement value so it can't possibly match against the thing it just replaced. Should i add that as a test just in case anyways?

@pelikhan
Copy link
Member

pelikhan commented Jul 4, 2024

What if you replace "" with ""?

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