const dd = `fsdfsd fsdfs from 'lodash'; debugger; fsdfs from "lodash"; fsdfs from 'lodash/isEqual'; fdsfds`; const reg = /(from\s['"])lodash(['"/])/g; const aa = dd.match(reg); const ss = dd.replace(reg, "$1lodash-es$2") debugger; console.log(ss);