I have some files with names starting with core- and following one or more words separated by hyphen, like this:
core-query
core-query-pagination
core-query-pagination-numbers
I'm creating a VS Code Snippet to transform the file name to get this result:
QUERY
QUERY PAGINATION
QUERY PAGINATION NUMBERS
- Remove
core- - Replace
-with - Capitalize every word
What I've got so far is this:
"${TM_FILENAME_BASE/([^-]+)(-*)/${1:/capitalize}${2:+ }/g}"
Output:
Core Query Pagination Numbers
asked Dec 8, 2024 at 0:06
1 Answer 1
Please check if the following works for you:
${TM_SELECTED_TEXT/(^core-)|(-)|([a-z]*)/${2:+ }${3:/upcase}/gm}
You can use the following if you do not need to remove the -.
${TM_SELECTED_TEXT/^core-(.*)/${1:/upcase}/gm}
answered Dec 8, 2024 at 0:09
Sign up to request clarification or add additional context in comments.
1 Comment
Germán Freixinós
This works! Thank you very much! I just tweaked it a bit to get exactly what I was looking for:
${TM_FILENAME_BASE/(^core-)|(-)|([a-zA-Z]+)/${2:+ }${3:/capitalize}/gi}.