Replace RegExp named captured group in Sublime Text & Visual Studio Code

I would like to do the replacement of the named capture group in these two IDE, Sublime Text and Visual Studio Code. And, I actually succeed in using IntelliJ WebStorm.

An example corpus was:

Title: Hamlet
Genre: Tragedy
Playwright: Williams Shakespere

Title: Woyzeck
Genre: Tragedy
Playwright: Karl Georg Büchner

and I used the following RegEx to retrieve the playwright

Playwright: (?<playwright>.*)

and replace this with the following RegEx to wrap in an XML format for the further analysis

<playwright>${playwright}</playwright>

Both Sublime Text and Visual Studio Code failed with this outcome:

Title: Hamlet
Genre: Tragedy
<playwright>${playwright}</playwright>

Title: Woyzeck
Genre: Tragedy
<playwright>${playwright}</playwright>

While WebStorm delivered the right results

Does anyone know how to make it with these two IDEs?

1 answer

  • answered 2022-05-04 10:31 Wiktor Stribiżew

    In SublimeText, the replacement pattern can contain named backreferences and should look like

    <playwright>$+{playwright}</playwright>
    

    In Visual Studio Code, named backreferences are not supported in the replacement patterns (the feature request did not collect enough community upvotes).

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum