1

I'm struggling to find a VSCode transformation regex that allows me take a string like this:
MyProject.Api/Data/RandomPath/Entities/User.ts
and produce:
MyProject.Api.Data.RandomPath.Entities

I can get this working in two passes; one to remove the last slash and filename, and another to replace the slashes with dots. Unfortunately VSCode snippets don't allow chaining, and I haven't been able to figure out how to combine these two passes into one.

Any help would be great, thanks!

Ben Wong
  • 339
  • 1
  • 8

1 Answers1

0

I got it! It's not pretty; but here it is as follows:

/[\\/\\\\]\\w+\\.\\w+$|(\\w+)(?:[\\/\\\\]\\w+\\.\\w+$)|(\\w+(\\.\\w+)?)|\\.|[\\/\\\\]/${2}${2:+.}${1}/g

Ben Wong
  • 339
  • 1
  • 8