Search by:
(\d+)
and replace with:
<span>\1</span>
Demo Regex
Sample source:
import re
regex = r"(\d+)"
test_str = "strings[abc123def456]strings"
subst = "<span>\\1</span>"
result = re.sub(regex, subst, test_str, 0)
if result:
print (result)
source
to share