3

I'm in VSCode trying to make snippets and get my head around some of the new regex replacement syntax.

What I want to do is populate parts of my template based on the filename. I can strip the unwanted extensions okay, but I can't capitalize the same value in the next variable.

I have these two lines:

"@Controller('/${1:${TM_FILENAME_BASE/(.*)\\.controller/$1/}}')", "export class ${1/(.*)/${1:/capitalize}/}Controller {",

The first strips filename and captures the value as $1 for the template. In the second line, I'm trying to use the value from $1 and run it through the capitalize filter.

Nothing I've tried works, although bashing my head against the keyboard feels kind of nice.

Has anyone cracked this nut?

Mark
  • 143,421
  • 24
  • 428
  • 436
Sebastian Nemeth
  • 5,505
  • 4
  • 26
  • 36

1 Answers1

12

This works at least as of v1.25:

"@Controller('/${TM_FILENAME_BASE/(.*)\\.controller/$1/}')",
"export class ${TM_FILENAME_BASE/(.*)$/${1:/capitalize}/}Controller {",

yields:

@Controller('/myGlobalSnippets')
export class MyGlobalSnippetsController {
Mark
  • 143,421
  • 24
  • 428
  • 436