I'm trying to transform file-name.dto.ts to FileName in a snippet.
${TM_FILENAME_BASE/^(.*)([^.*]).*/${1:/pascalcase}2ドル/}
However, I'm not quite sure how to transform the second capture group or third.
If we don't wrap with a parenthesis, does it mean we don't capture?
export class ${TM_FILENAME_BASE/^(.)([^.]*).*/${1:/upcase}2ドル/}Input {2ドル},
export class ${TM_FILENAME_BASE/^(.*).*/${1:/pascalcase}2ドル/}Output {},
1 Answer 1
For the first line (the Input line), try this:
"export class ${TM_FILENAME_BASE/^([^-]*)-([^.]*).*/${1:/pascalcase}${2:/pascalcase}/}Input {2ドル},"
${TM_FILENAME_BASE}alone gets you tofile-name.dtoCapture group 1
^([^-]*)gets you the part before the first-Match the
-but you will ignore it in the output so it doesn't need to be in a capture group.Capture group 2
([^.]*)after the-until the first.The rest
.*will match.dtowhich again will be ignored so it doesn't need to be a capture group, but must be matched - you will effectively replace it with nothing.
Replacing with the transform: ${1:/pascalcase}${2:/pascalcase} so the first letter of both capture groups will be capitalized, the rest lower case.
On the Output line, if you are looking for this result:
export class FileNameOutput {}
use
"export class ${TM_FILENAME_BASE/^([^-]*)-([^.]*).*/${1:/pascalcase}${2:/pascalcase}/}Output {},"
Just in case you don't realize it, in your code:
export class ${TM_FILENAME_BASE/^(.)([^.]*).*/${1:/upcase}2ドル/}Input {2ドル},
that last {2ドル} is NOT referring to any capture group - it is outside any transform. It is only referring to a tabstop - where your cursor will go. Let me know if it is your intention that that final {2ドル} actually be a transformed capture group.
1 Comment
Explore related questions
See similar questions with these tags.
Outputline? The same thing, justexport class FileNameOutput {}?