-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
using regex to split and replace text in a string #26
Comments
The bug here is the docs. I likely copied them from elsewhere. I just never got around to actually implementing the split or replace routines. You can either implement them for your specific use case, or you or someone could submit a PR adding them to the API of this crate. (And if you do that, I'd suggest copying what is in the In general this crate exposes PCRE2 stuff for my own purposes in ripgrep. If folks want additional stuff I'll do my best to merge patches. But I do not have time to do it myself. |
Also, I would strongly urge you to use the regex crate if you can. I realize PCRE2 has a bunch of fancy features, but if you're processing untrusted input from somewhere, it's very easily to fall victim to ReDoS. If you do want to use the regex crate but don't know how to avoid using look-around or similar fancy features, I can try to help if you want to post a question to the regex repo: https://github.com/rust-lang/regex/discussions --- If you do, just please try to include a full minimal example of what you're trying to do: your inputs, what you've tried, the output you get and the output you want. |
ah i see, yes unfortunately look arounds are necessary for our use case and are already pretty deeply embedded into our work flow. |
I don't have much direct experience with |
ended up adding split / replace functions if you could take a look at the PR whenever you have the time! |
Hi @priyankat99 , I would like to know what is wrong with this PR and when can I use this PR, #27, / replace functions is blocking my work. |
hi @zong-zhe i dont think anything is wrong with the PR, it just never got reviewed. ive been using the replace and split functions for a while and its working just fine feel free to use my branch of pcre2 for the replace functions by adding this to your Cargo.toml pcre2 = { git = "https://github.com/priyankat99/rust-pcre2", tag = "0.0.3"} |
rust-pcre2/src/bytes.rs
Line 400 in 2f87eb9
how can this regex be used to split / replace text in a string? i tried using the split function but is erroring with the message "required for
Regex
to implementPattern<'_>
". Not sure if I am misunderstanding how to use the regex to split strings or if this is a bug?The text was updated successfully, but these errors were encountered: