📌  相关文章
📜  python替换正则表达式 - Python代码示例

📅  最后修改于: 2022-03-11 14:45:55.133000             🧑  作者: Mango

代码示例5
# Limit the maximum number of pattern occurrences to be replaced
# replace three occurrence of space with '-'
target_str = "a b c d e f"
res_str = re.sub(r"\s", "-", target_str, count=3)
print(res_str)
# Output a-b-c-d e f