Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

The filename is currently filename.dto.ts

I'm trying to transform filename.dto.ts to FilenameInput or FilenameOutput

However, it seems this is not a way to select the second group using regex.

How can I properly select the second regex group and transform it?

export class ${TM_FILENAME_BASE/^(.)|(.dto)$/${1:/upcase}$2/}Input {}
export class ${TM_FILENAME_BASE/(.dto)//}Output {}`

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.0k views
Welcome To Ask or Share your Answers For Others

1 Answer

Try this:

export class ${TM_FILENAME_BASE/^([^.]*).*/${1:/pascalcase}$2/}Input {}"

Your first capture group is everything up to the first ..

Then you need to match everything else .* will match .dto (and don't replace it with anything since you don't want it in your result).

You do not need a second capture group but the previous version I showed did have a capture group 2 (but it wasn't transformed) and it looked like:

export class ${TM_FILENAME_BASE/^(.)([^.]*).*/${1:/upcase}$2/}Input {}


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...