You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes it would be helpful to have part of the regex query written as a literal, rather than escaping all regex-like syntax. For example, if you wanted to match exact const generics below with any function name:
foo::<{FOO[1].len()}>();
Currently, the query must be written as \w+::<\{ FOO\[1]\.len\(\) \}>\(\); (some closing escapes optional).
With a new flag that allows for a plaintext group, this becomes easier to read and write. Choosing an arbitrary e for e xact:
\w+::(?e:<{FOO[1].len()}>();)
I know of no prior art here but it seems like a relatively simple feature to help reduce mistakes, akin to verbose mode.
The text was updated successfully, but these errors were encountered:
The prior art is \Q...\E. I'm generally opposed to it because it doesn't do what you think it does. In your example, the closing paranthesis is found well before your intended closing paranthesis. This is a general problem with the technique and I don't know how to avoid it.
Your better off just using regex::escape for literal parts and using standard interpolation facilities.
Describe your feature request
Sometimes it would be helpful to have part of the regex query written as a literal, rather than escaping all regex-like syntax. For example, if you wanted to match exact const generics below with any function name:
Currently, the query must be written as
\w+::<\{ FOO\[1]\.len\(\) \}>\(\);
(some closing escapes optional).With a new flag that allows for a plaintext group, this becomes easier to read and write. Choosing an arbitrary
e
for e xact:I know of no prior art here but it seems like a relatively simple feature to help reduce mistakes, akin to verbose mode.
The text was updated successfully, but these errors were encountered: