1. Regular expression
Match:
\b0*([1-9][0-9]*|0)\b
Replace:
\1
2. Python code
import re
subject = '0011'
result = re.sub(r"\b0*([1-9][0-9]*|0)", r"\1", subject)
Python 正则表达式去除前导0
最新推荐文章于 2024-06-25 16:48:25 发布
1. Regular expression
Match:
\b0*([1-9][0-9]*|0)\b
Replace:
\1
2. Python code
import re
subject = '0011'
result = re.sub(r"\b0*([1-9][0-9]*|0)", r"\1", subject)