I am struggling with regular expressions and how to use them in snippets in VSCode and I could really use some help (I am a beginner in that area). I have two regexp:
- the first one is here to remove the extension from a file path:
(.*)\.[^.]+$
- the second one would output all the occurrences of a backlash in the file path:
/(\\)/g
I would like to group them into one regex to use in a user code snippet (html) in VSCode.
From the following input: C:\folder0\myhtml.html
I would like to get the following output from the code snippet using transformations: C:/folder0/myhtml
(backlashes are replaced with forward ones and the extension is removed).
I know how to write snippets that do it independently:
${TM_FILEPATH/(.*)\\..+$/$1/}
would produce C:\folder0\myhtml
${TM_FILEPATH/(\\\\)/\\//g}
would produce C:/folder0/myhtml.html
TM_FILEPATH
being C:\folder0\myhtml.html
in my example. But I cannot combine them.
I have first tried to combine the regex in https://regex101.com/ like this:
(\\)(.*)\.[^.]+$
but the result is not what I expect.