VS代码段中的变量转换面临问题



我有下面的VS代码全局片段的代码

"prints formated path": {
"prefix": "pp",
"body": [
"$BLOCK_COMMENT_START",
"File Path ->     "${TM_FILEPATH/\///g}"",
"$BLOCK_COMMENT_END",
],
"description": "prints path"
},

并且上面片段的输出是

"""
File Path ->     "D:tpNew folder (6)4. Chapter 4 Packagingmy_packagetest.py"
"""

预期输出为

"""
File Path ->     "D:/tp/New folder (6)/4. Chapter 4 Packaging/my_package/test.py"
"""

实际上,我想用替换">\">

在网上搜索了太多之后,我找到了这个关于VS代码中的变量转换的页面,但它对我没有帮助。如果你知道问题的解决方案,请建议

问题是正则表达式的解析,您必须添加一个捕获组来识别反斜杠,并且必须转义替换斜杠

"prints formated path": {
"prefix": "pp",
"body": [
"$BLOCK_COMMENT_START",
"File Path ->     "${TM_FILEPATH/(\\)/\//g}"",
"$BLOCK_COMMENT_END",
],
"description": "prints path"
}

相关内容

  • 没有找到相关文章

最新更新