VSCODE摘要正则是提取目录和替换斜线?

发布于 2025-01-25 00:27:38 字数 298 浏览 2 评论 0原文

我正在努力寻找一个Vscode Transformation Regex,让我采用这样的字符串:
myproject.api/data/randompath/entities/user.ts
和生产:
myproject.api.data.randompath.entities

我可以在两个通过中获得此功能;一个用于删除最后一个斜线和文件名,另一个用点替换斜线。不幸的是,VSCODE片段不允许链接,我还没有弄清楚如何将这两个传球组合成一个。

任何帮助都很好,谢谢!

I'm struggling to find a VSCode transformation regex that allows me take a string like this:
MyProject.Api/Data/RandomPath/Entities/User.ts
and produce:
MyProject.Api.Data.RandomPath.Entities

I can get this working in two passes; one to remove the last slash and filename, and another to replace the slashes with dots. Unfortunately VSCode snippets don't allow chaining, and I haven't been able to figure out how to combine these two passes into one.

Any help would be great, thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小女人ら 2025-02-01 00:27:38

我得到了它!不漂亮;但这是如下:

/[\\/\\\\] \\ w+\\。 w+\\。\\ w+$)|(\\ w+(\\。\\ w+)?)| \\。 $ {1}/g

I got it! It's not pretty; but here it is as follows:

/[\\/\\\\]\\w+\\.\\w+$|(\\w+)(?:[\\/\\\\]\\w+\\.\\w+$)|(\\w+(\\.\\w+)?)|\\.|[\\/\\\\]/${2}${2:+.}${1}/g

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文