Maybe,(也许,)
(?!^+)[^d
]+
replaced with an empty string would simply do that.(替换为空字符串就可以做到这一点。)
The first statement,(第一个陈述,)
(?!^+)
ignores the +
at the beginning of the string, and the second one,(忽略字符串开头的+
,第二个忽略,)
[^d
]+
ignores digits, newlines and carriage returns in the string.(忽略字符串中的数字,换行符和回车符。)
Test(测试)
const regex = /(?!^\+)[^\d\r\n]+/g; const str = `+614a24569953`; const subst = ``; const result = str.replace(regex, subst); console.log(result);
If you wish to simplify/update/explore the expression, it's been explained on the top right panel of regex101.com .(如果您想简化/更新/探索该表达式,请在regex101.com的右上方面板中进行说明 。)
You can watch the matching steps or modify them in this debugger link , if you'd be interested.(如果您有兴趣,可以观看匹配的步骤或在此调试器链接中对其进行修改。) The debugger demonstrates that how a RegEx engine might step by step consume some sample input strings and would perform the matching process.(调试器演示了RegEx引擎如何逐步使用一些示例输入字符串并执行匹配过程。)
RegEx Circuit(RegEx电路)
jex.im visualizes regular expressions:(jex.im可视化正则表达式:)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…