12345678如何用正则表达式替换成12,345,678?
如题:
例如:12345678 替换成12,345,678
从后数起,每隔3个,就加一个“,”号…
解:
<script type="text/javascript"> var s = "12345678"; alert(s.replace(/(\d)(?=(\d{3})+$)/g, "$1,")); </script>
12345678如何用正则表达式替换成12,345,678?
如题:
例如:12345678 替换成12,345,678
从后数起,每隔3个,就加一个“,”号…
解:
<script type="text/javascript"> var s = "12345678"; alert(s.replace(/(\d)(?=(\d{3})+$)/g, "$1,")); </script>