kotlin.text.Regex.replace interprets \ as a special character not just in the match string, but also in the replacement string. You have to quote the replacement string with java.util.regex.Matcher.quoteReplacement.
I've added a test that passes on this branch and fails on the main branch.
Skip Pull Request Checklist:
- REQUIRED: I have signed the Contributor Agreement
- REQUIRED: I have tested my change locally with
swift test - OPTIONAL: I have tested my change on an iOS simulator or device
- OPTIONAL: I have tested my change on an Android emulator or device
- AI was used to generate or assist with generating this PR. Please specify below how you used AI to help you, and what steps you have taken to manually verify the changes.
Cursor tracked the bug down and fixed it; I wrote the test and verified that it fails on main and passes on this branch.