在蟒蛇中
re.sub(r"(?<=.)(?=(?:...)+$)", ",", stroke )
Run Code Online (Sandbox Code Playgroud)
用三元组分割一个数字,例如:
echo 123456789 | python -c 'import sys;import re; print re.sub(r"(?<=.)(?=(?:...)+$)", ",", sys.stdin.read());'
123,456,789
Run Code Online (Sandbox Code Playgroud)
如何用 bash/awk 做同样的事情?