function to(dte: string, chars: string[]): string[] {
  const regex = new RegExp(`[${chars.join('')}]`, 'g');
  return dte.split(regex);
}

使用示例:

const result = to('Hello, World!', [' ', ',']);
console.log(result); // Output: ['Hello', 'World!']
写一个ts函数todtestringcharsstringstring根据特定字符串分割一个字符串dte要使用正则

原文地址: http://www.cveoy.top/t/topic/h7Sk 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录