0

How can I get the relative_filepath without the extension and backslash change ?

I found two transforms:

  1. "${RELATIVE_FILEPATH/[\\]/\//g/}"
  2. "${RELATIVE_FILEPATH/(.js)//}"

If the relative file path is \aaa\bbb\ccc.js

I tried this:

/${RELATIVE_FILEPATH/((.js))}|/[\\]/${1://}${2://g/}/}

I want to get text like this: /aaa/bbb/ccc

Thank you.

marc_s
759k185 gold badges1.4k silver badges1.5k bronze badges
asked Feb 22 at 0:06
1
  • thank for correct words. Commented Feb 24 at 1:43

1 Answer 1

0

Try this snippet:

"Remove extension and swap to forward slash": {
 "prefix": "t2",
 "body": [
 // "${RELATIVE_FILEPATH}",
 "/${RELATIVE_FILEPATH/.js|(\\\\)/${1:+\/}/g}",
 ],
 "description": ""
},

Note the double escapes in .js|(\\\\) are necessary.
And I added the + to the ${1:+\/}.

answered Feb 22 at 3:24
Sign up to request clarification or add additional context in comments.

1 Comment

thank you for your help. Thanks to you you saved me time. Your code works correctly. ^^

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.