【发布时间】:2013-08-16 12:35:36
【问题描述】:
作为可视化的一部分,我想为字符串中的任何数字(连续的数字字符串)添加数千个分隔符。它不需要考虑数字的上下文,例如
1234e+56789 Nokia 3210s cost $123456.7890 and my phone number is 123-4567-89012.
变成
1,234e+56,789 Nokia 3,210s cost $123,456.7,890 and my phone number is 123-4,567-89,012.
我知道我可以反转字符串,将 \d{3}(?=\d) 替换为 $&, 并再次反转它,但是有没有办法只使用正则表达式(最好只有一个)?
【问题讨论】:
-
看起来 Notepad++ 不支持正向前瞻...所以最好写一个小脚本。
-
@epascarello 确实如此。确保更新到 NP++ 6。
-
啊我坐在 5.X :)
标签: javascript regex notepad++