Skip to content

Conversation

@TwoFX
Copy link
Member

@TwoFX TwoFX commented Oct 27, 2025

This PR defines String.Slice.replace and redefines String.replace to use the Slice version.

The new implementation is generic in the pattern, so it supports things like "education".replace isVowel "☃!" = "☃!d☃!c☃!t☃!☃!n". Since it uses the ForwardSearcher infrastructure, String patterns are searched using KMP, unlike the previous implementation which had quadratic runtime. As a side effect, the behavior when replacing an empty string now matches that of most other programming languages, namely "abc".replace "" "k" = "kakbkck".

@TwoFX TwoFX added the changelog-library Library label Oct 29, 2025
@TwoFX TwoFX force-pushed the markus/replace-replace branch from e3b5f28 to 90dfd36 Compare October 29, 2025 06:26
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Oct 29, 2025
@leanprover-community-bot
Copy link
Collaborator

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 106b0fa661d96fd1fa6ff96e2ee5f55f23f307f2 --onto 19533ab1d4312903f98ff0429a5962db24ce402b. You can force Mathlib CI using the force-mathlib-ci label. (2025-10-29 07:31:09)

@leanprover-bot
Copy link
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 106b0fa661d96fd1fa6ff96e2ee5f55f23f307f2 --onto d3dda9f6d4428a906c096067ecb75e432afc4615. You can force reference manual CI using the force-manual-ci label. (2025-10-29 07:31:11)

@TwoFX TwoFX marked this pull request as ready for review October 29, 2025 07:48
@TwoFX TwoFX enabled auto-merge October 29, 2025 07:48
@TwoFX TwoFX added this pull request to the merge queue Oct 29, 2025
Merged via the queue into leanprover:master with commit 1674295 Oct 29, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-library Library toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants