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.

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:+\/}.

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

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.