vscode正则表达式批量替换和提取文本

发布时间 2023-09-07 16:50:16作者: 看风景就

在有大量模块路径需要提取模块名时候,可使用vscode正则表达式替换快速提取文本

例如: 提取固定模块名

aaa\xxx\resources\pu\pu\poorder\bbb\index.html
aaa\xxx\resources\pu\pu\constance\bbb\index.html

.*(pu\\pu\\[^\\]+).* 替换为 $1

提起后为

pu\pu\poorder
pu\pu\constance


例如: 提取不固定模块名

aaa\xxx\resources\pu\pu\puinvoice\bbb\index.html
aaa\xxx\resources\to\to\m5xmaintain\bbb\index.html

.*resources\\([^\\]+\\[^\\]+\\[^\\]+).* 替换为 $1

提起后为

pu\pu\puinvoice
to\to\m5xmaintain