Home > Software engineering >  VSCode Snippet: how to trim the path into the last directory name?
VSCode Snippet: how to trim the path into the last directory name?

Time:09-12

How can I use regex to transform:

C:\Repos\test\src\test\test-test\two-words

Into the last iteration after the last slash:

two-words

In order to make a VSCode snippet?

I thought of using:

${TM_DIRECTORY/.*?\\\\([a-zA-Z] )$/$1/}

But I think it's too complecated and it only worked for one word after the last slash.

Thanks for your help!

CodePudding user response:

try this snippet

${TM_DIRECTORY/.*\\\\([^\\\\] )$/$1/}
  • Related