Jar*_*red 5 regex visual-studio-code
我已经设置了一些片段并按照我的意愿工作,但是我很难让一个片段起作用,我相信我需要进行多次转换?
本质上,我为我的一个组件定义了一个 TypeScript 接口。
即IRadioButtonListProps.ts这是在一个Interfaces文件夹内。该Interfaces文件夹有一个名为的同级文件夹,Theme其中包含一个名为IRadioButtonListTheme.ts
在IRadioButtonListProps我内部,我试图剔除整个界面。我目前拥有的代码片段将界面存根,例如......
import * as React from 'react';
import IRadioButtonListPropsTheme from '../Theme/IRadioButtonListPropsTheme';
export interface IRadioButtonListPropsProps {
...props...
}
export default IRadioButtonListPropsProps;
Run Code Online (Sandbox Code Playgroud)
代码段内的导入行是...
"import I${TM_FILENAME_BASE/(.*)\\..+$/$1/}Props from './Interfaces/I${TM_FILENAME_BASE/(.*)\\..+$/$1/}Props';"
Run Code Online (Sandbox Code Playgroud)
我想要发生但似乎无法弄清楚的是如何同时删除“道具”一词。所以import IRadioButtonListPropsTheme...我会得到 import import IRadioButtonListTheme...。
同时,我想删除所有扩展名,包括 *.abc.abc(“两个”扩展名)和 *.abc(一个简单扩展名)形式的扩展名。
这可能吗?
目前尚不清楚您要做什么,但请尝试:
"import ${TM_FILENAME/((\\w*)Props)*?(\\..*)/$2/}Theme from './Interfaces/${TM_FILENAME/((\\w*)Props)*?(\\..*)/$2/}Theme';"
Run Code Online (Sandbox Code Playgroud)
结果是:
import IRadioButtonListTheme from './Interfaces/IRadioButtonListTheme';
Run Code Online (Sandbox Code Playgroud)
从IRadioButtonListProps.ts
和
import CheckboxListTheme from './Interfaces/CheckboxListTheme';
Run Code Online (Sandbox Code Playgroud)
从CheckboxListProps.test.tsx
[编辑]这是一个更简单的版本,我认为也有效:
"import ${TM_FILENAME/(Props)*?(\\..*)//}Theme from './Interfaces/${TM_FILENAME/(Props)*?(\\..*)//}Theme';"
Run Code Online (Sandbox Code Playgroud)