前任:
"Hi, my name is Rafael and I live in Brazil."
我需要使用express 的方法获取人名和您所在的国家/地区,例如:
"Hi, my name is %name% and i live in %country%"
存在,一些工具,来做到这一点?
可能是,
(Hi, my name is )[^\r\n]*( and I live in )[^.\r\n]*.
替换为,
$1%name%$2%country%.
可能在某种程度上接近这里可能需要的东西,但不确定。
const regex = /(Hi, my name is )[^\r\n]*( and I live in )[^.\r\n]*./g;
const str = `Hi, my name is Rafael and I live in Brazil.`;
const subst = `$1%name%$2%country%.`;
const result = str.replace(regex, subst);
console.log(result);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句