我有这个javascript正则表达式:
let output = 'This role involves:\n - Steering the direction of universal expansion and resource allocation.';
console.log('before:', JSON.stringify(output));
output = output.replace(/[^a-zA-Z0-9 _-\s\r\n\t]/gi, '');
console.log('after:', JSON.stringify(output));
// This role involvesn - Steering the direction of universal expansion and resource allocation
它不会留在那里
\n
,而是用 n
代替它
其次,我想将
- Steering
替换为一个空格,然后是减号,然后是另一个空格,然后是单词 - Steering
。但似乎这不仅仅是一个普通的空间。或者我如何调试最好?