获取第一个.前面的字符串,以及后面的字符串:

const transform = str => {
  str.replace(/([^\.]*)\.(.*)/, function($0, $1,$2){
    // $0是匹配的完整的字符串
    console.log($1,":", $2);
  });
}
transform("abc.def.ghi")
// abc:def.ghi

或者

const transform = str => {
  str.replace(/(.*)(?:\.)(.*)/, function ($0, $1, $2) {
    console.log($1, ":", $2);
  });
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-21
  • 2022-12-23
  • 2021-12-24
  • 2022-12-23
  • 2022-12-23
  • 2021-11-15
猜你喜欢
  • 2021-06-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-03
  • 2022-12-23
相关资源
相似解决方案