0

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
  1. Remove core-
  2. Replace - with
  3. 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

0

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

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}.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.