Require matching number of hashes for Rust-style raw strings?
Closed this issue · 2 comments
Hello,
Is there any way to create a regular expression that requires two matching groups to match each other? Specifically, I want to create a regex that would match a Rust-style raw string (r(#*)"..."(#*)
where the two (#*)
groups have to have the same number of #
s). Right now my regex is r#"(?:[^("#r)])"#r
(I want a matching r
on each side as well...), but that will only match exactly one #
on each side, no less, no more.
If there is a way to do this, please let me know. If there is no way to do this, will there be a way in future versions or will I be stuck with single #
raw strings?
Hello, you should have a look at #351, as I think this is a duplicate of this.
For the group matching part, this is impossible to do that with pure regexes I am afraid.
Alright. looks like I'll just have to use r#"..."#r
for the mean while. Thanks for letting me know.