Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a function to replace matches with a callback #2

Open
ryanmiville opened this issue Dec 4, 2024 · 1 comment · May be fixed by #3
Open

Add a function to replace matches with a callback #2

ryanmiville opened this issue Dec 4, 2024 · 1 comment · May be fixed by #3
Labels
help wanted Contributions encouraged

Comments

@ryanmiville
Copy link

pub fn replace_map(
  each pattern: Regexp,
  in string: String,
  with substitute: fn(Match) -> String,
) -> String

I have found myself rewriting this function a few times. It feels useful and appropriate for it to exist in the library.

Both erlang and javascript accept a callback function, so the ffi is mostly coercing the target platform's parameters into a Match. You can see my implementation in this fork.

@lpil
Copy link
Member

lpil commented Dec 5, 2024

Sounds like a good function to have! Unsure about the name, but we can bikeshed on that

@lpil lpil added the help wanted Contributions encouraged label Dec 5, 2024
@ryanmiville ryanmiville linked a pull request Dec 5, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Contributions encouraged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants