devicescript icon indicating copy to clipboard operation
devicescript copied to clipboard

Added string.replace() and .replaceAll()

Open hkubus opened this issue 1 year ago • 5 comments

finishes 1 task off of #683

hkubus avatar Jul 03 '24 11:07 hkubus

@microsoft-github-policy-service agree

hkubus avatar Jul 03 '24 11:07 hkubus

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.

hkubus avatar Jul 03 '24 15:07 hkubus

what if searchvalue equals replace value?

pelikhan avatar Jul 03 '24 20:07 pelikhan

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?

hkubus avatar Jul 03 '24 21:07 hkubus

What if you replace "" with ""?

pelikhan avatar Jul 04 '24 11:07 pelikhan