Add support for additional characters in group names#649
Conversation
We have an application that requires the ability to use field access notation, which includes periods and square braces in group names. This commit adds support and tests for these additional characters.
|
So I think there are two problems with this PR. The first one is that this only changes what's allowed in the syntax, but doesn't modify replacement expansion to account for the new characters. The second one is that if we do modify expansion to account for the new characters, then sadly, this becomes a breaking change. Consider this case: The current (and correct) result is The only way I can think of to do this without making it a breaking change would be to require the use of braces when using characters in a capture group outside of I'll look into doing this. |
This slightly expands the set of characters allowed in capture group
names to be `[][_0-9A-Za-z.]` from `[_0-9A-Za-z]`.
This required some delicacy in order to avoid replacement strings like
`$Z[` from referring to invalid capture group names where the intent was
to refer to the capture group named `Z`. That is, in order to use `[`,
`]` or `.` in a capture group name, one must use the explicit brace
syntax: `${Z[}`. We clarify the docs around this issue.
Regretably, we are not much closer to handling #595. In order to
support, say, all Unicode word characters, our replacement parser would
need to become UTF-8 aware on `&[u8]`. But std makes this difficult and
I would prefer not to add another dependency on ad hoc UTF-8 decoding or
a dependency on another crate.
Closes #649
We have an application that requires the ability to use field access
notation, which includes periods and square braces in group names. This
commit adds support and tests for these additional characters.