Skip to content

Conversation

@dbuenzli
Copy link
Contributor

This PR adds the functions string replacing functions discussed in #14137 it is built (two last commits) on top of the PR of search primitives #14381.

@nojb nojb added the stdlib label Jan 6, 2026
@nojb nojb self-assigned this Jan 7, 2026
Copy link
Contributor

@nojb nojb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

A second core dev approval is needed before merging.

Copy link
Member

@Octachron Octachron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The replace_all function is clearly useful and expected.

Overall, I agree with the labels for opposed arguments with a shared type.

I was a bit wary about the potential performance trap of replace_first or replace_last, but in fact the function are probably hard to use to emulate replace_all in an inefficient way (without resorting to testing physical equality). I am still not completely sure if those two functions would be really used a lot, but people would probably expect them to exist at least for symmetry's sake.

Globally, I agree that this PR should be part of the "String API improvement" bundle for 5.5 .

@dbuenzli
Copy link
Contributor Author

I am still not completely sure if those two functions would be really used a lot, but people would probably expect them to exist at least for symmetry's sake.

I'm sure they will be, I can think of quite a few times where I had to replace a given suffix by something else (example here).

Thanks for the approval. Rebased.

@nojb nojb added the merge-me label Jan 19, 2026
@nojb nojb merged commit 3c978d3 into ocaml:trunk Jan 19, 2026
35 checks passed
@dbuenzli dbuenzli deleted the string-replace branch January 19, 2026 16:43
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.

4 participants