Skip to content

Add String.replacing(:maxReplacements:with:) with a closure#41

Merged
marcprux merged 1 commit intoskiptools:mainfrom
dfabulich:regex-replacing-closure
Apr 18, 2026
Merged

Add String.replacing(:maxReplacements:with:) with a closure#41
marcprux merged 1 commit intoskiptools:mainfrom
dfabulich:regex-replacing-closure

Conversation

@dfabulich
Copy link
Copy Markdown
Contributor

#expect("1zz1" == "1z1".replacing(try Regex("([a-z])"), with: { match in
    return match[1].substring! + match[1].substring!
}))

This lets you replace a matching groups with dynamic content.

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.

I wrote the test; Cursor wrote the code. (It's not a lot of code.) The test fails on the main branch, and passes here.

@cla-bot cla-bot Bot added the cla-signed label Apr 15, 2026
@marcprux marcprux merged commit 1b2841c into skiptools:main Apr 18, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants