Are named capture groups supported? If so, how to engage?

Viewed 453

I understand that VSCode uses the JavaScript regex engine for its functionality.

The latest JavaScript specification allows for named capture groups to be used.

However, I am at a loss in understanding whether this is enabled in VSCode v1.43?

I am using the following notations in the general find command:

(?<name-of-capture>pattern to find)( other stuff )(\k<name-of-capture>)

(?<name-of-capture>pattern to find)( other stuff )(\g<name-of-capture>)

I have also used the combinations of \k'name' and \g'name' and these have no effect.

If anyone has insights into this I would appreciate to hear.

1 Answers

If you want to use an inline backreference, they work in VSCode.

(?<group>[a-z]+) \d+ \k<group>

matches abc 1 abc.

However, new JavaScript-like $<group> replacement does not work, .NET-style replacement backreference, ${group}, does not work either, probably, due to the issue referred to by @JW.

NOTE: They say they need 20 votes on the issue and there are 3 days to go before they close the issue and turn down the suggestion to introduce backreferences in replacement. If you want this feature to be implemented, please consider voting for that issue.

Related