Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Dec 8, 2025. It is now read-only.

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

Open
hkubus wants to merge 2 commits into microsoft:main
base: main
Choose a base branch
Loading
from hkubus:string-replace

Conversation

@hkubus
Copy link

@hkubus hkubus commented Jul 3, 2024

finishes 1 task off of #683

Copy link
Author

hkubus 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?

Copy link
Author

hkubus 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 reacted with thumbs up emoji

Copy link
Member

pelikhan commented Jul 3, 2024

what if searchvalue equals replace value?

Copy link
Author

hkubus 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 reacted with thumbs up emoji

Copy link
Member

pelikhan commented Jul 4, 2024

What if you replace "" with ""?

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

Reviewers

1 more reviewer

@pelikhan pelikhan pelikhan left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /