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
Substring Value #11
Comments
I don't understand the question. Could you please explain what problem you're trying to solve? What have you tried? Have you looked at the examples in the docs? https://docs.rs/aho-corasick/0.6.3/aho_corasick/ |
I want to be able to do the following
where |
I've checked the documentation and it seems to be only useful when using |
@AlexCreamer Could you take a look at the second example in the docs here please? https://docs.rs/aho-corasick/0.6.3/aho_corasick/ --- In particular, if you replace this: let aut = AcAutomaton::new(vec!["apple", "maple"]); with this: let aut = AcAutomaton::new(vec!["I like maple"]); then does that do what you want? |
If you want the actual text that was matched, then all you need to do is ask |
Check out the fourth example here: https://docs.rs/aho-corasick/0.6.3/aho_corasick/ |
What if I don't know the text to match, all I have is index, such as: |
@AlexCreamer Please, please, please help me help you. Describe the problem you're trying to solve. I don't understand what you're asking. Therefore, I don't know how to help you. Can you show code? Can you say more about what you've tried? Did you actually try running the fourth example? Does it do what you want? If not, what's missing? |
Here's an example code I'm working on: https://is.gd/zsVtBo I want the remove_brackets function to remove brackets and anything withint the brackets out of a string. The brackets "()" occur only once and they occur at the end of a string, as such: "Lorem Ipsum (crap)", where I would only keep the string "Lorem Ipsum". |
Why not just use the regex crate to do this? |
Coming from a Java background I was hoping for something similar to it's "substring" functionality where I can just input index's. Plus I'm not familiar with the regex crate. I'll look into it, thanks. Feel free to close this issue. |
@AlexCreamer Sure, you don't need a regex for this. You could do something very simple: https://is.gd/cSkowC Aho-Corasick definitely seems like the wrong tool for this. It would be helpful to know how you wound up here so we can fix that in the future. Aho-Corasick is a relatively specialized algorithm for efficient multiple pattern search. If you don't need super fast multiple pattern search, then Aho-Corasick isn't something you should be caring about. See more here: https://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_algorithm |
I searched for "substring" on crates.io and it was one of the only relevant crates. |
@AlexCreamer OK, thanks so much, I filed an issue so that this gets improved: rust-lang/book#583 |
Hi, how do I use the following crate to return a string value so that "I like maple apples." Would return "I like maple" on pati: 0, start: 0, end: 11.
The text was updated successfully, but these errors were encountered: