Reputation: 15829
I want to see how many characters the regex has looked at before it succeeds or fails (to support incrementally re-lexing something). I haven't noticed a direct way to do this in the Rust regex library's API.
If I could somehow intercept the &str
I give to library, I could record the furthest character it's had to observe. I'm not sure how to do this, as I am new to Rust. If this were Java, I would use a proxy/implement CharSequence
.
Bonus points if it works with RegexSet
.
Upvotes: 0
Views: 108
Reputation: 15354
This looks like an instance of the XY problem. Namely, it sounds like what you're asking is whether the regex crate supports incremental searching on streams. More specifically, whether you can use the regex crate to search text that does not necessarily live contiguously in memory.
In any case, the answer to both questions is: you can't, in general.
If you're curious about the complexities of supporting search on streams, issue 425 tracks that feature.
Upvotes: 5