I trying to build build vscode snippets based on file name. For example: from file first.actions.ts
I'm generating First = 42;
via const ${TM_FILENAME_BASE/(.*?).actions/${1:/capitalize}/g} = 42;
.
However in case when file name is e.g. first-module.actions.ts
I'm generating First-Module = 42;
and this code contains syntax error. I want const FirstModule = 42;
.
I'm looking for some trick to merge regular expression for cutting .actions
and remove all -
marks.
Try:
"const ${TM_FILENAME_BASE/([^-]*)-?(.*)\\.actions/${1:/capitalize}${2:/capitalize}/g} = 42;"
capture everything up to the first -
,
ignore an optional -
, and
.actions
Assuming you want first-module.actions.ts
=> FirstModule
Note your extension separator .
should be double-escaped to work properly.