Make regexes almost first-class Rust syntax (like Perl) #1118
daniel-pfeiffer
started this conversation in
General
Replies: 1 comment 2 replies
-
I'm going to have to decline for a few reasons:
I think that #709 is a far more likely path. By requiring users to use raw strings, it vastly simplifies its implementation. The other advantage is that it works today. You can define that macro yourself in your crate in a couple lines. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Regex::new(r"…").unwrap()
looks rather heavy and unelegant (coming from Perl where I could just/…/
.) To make it a bit leaner, I propose implicitly raw-string procedural macro equivalent of:These could then be used as
re!(a[)}](.?)\(a)
. For sets this is not directly possible, because the separator is indistinguishable from regex comma. As a compromise, it could require literal commas to need masking. E.g. a set of 2:re_set![a.?[,]a, o.?\,o]
.Since the macro delimiters, when used in the regex, must be balanced or masked as in
re!(…[)]…\(…)
above, I don't see a possible conflict.Beta Was this translation helpful? Give feedback.
All reactions