我有:
const abc = require('abc');
const def = require('de-f');
const ght = require('ght');
我需要在PhpStorm中用 Ctrl + R (替换选项)将其更改为:
import abc from 'abc';
import def from 'de-f';
并拥有相同的内容:
const ght = require('gth');
所以我有意想在第一个输入中写这样的东西:
const\s([ad])
在const
和a
中抓取d
+空格+第一个字母(abc
和def
)。
但是如何捕捉整个单词(abc
和def
)+ =
符号和下一个require
?
答案 0 :(得分:0)
我猜你可以尝试匹配这个正则表达式模式:
.*\s(\w+)\s=\s.*\('(.*)\'\);
并替换为:
import $1 from '$2';