The regex [^a-z0-9%*][a-z0-9%]{3,}(?=[^a-z0-9%*])
is not supported by Rust's default regex
create due to positive look-ahead ( ?=
):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
regex parse error:
[^a-z0-9%*][a-z0-9%]{3,}(?=[^a-z0-9%*])
^^^
error: look-around, including look-ahead and look-behind, is not supported
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
)
What's the optimal way to rewrite it or make it working?
I've found fancy-regex
crate but i'd like to avoid using both crates (or prefer fancy over default) just for one missing feature.
PS. here it is at least one expected matches example .
Place your current matching pattern into a capture group, and also match (but do not capture) the term currently inside the lookahead:
([^a-z0-9%*][a-z0-9%]{3,})(?:[^a-z0-9%*]|$)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.