The default strings is:
strings123[abc123def456]strings456
Add tag for number:
strings[abc<span>123</span>def<span>456</span>]strings
Search by this:
(d+)
and replace by :
<span>1</span>
Regex Demo
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)
2.1m questions
2.1m answers
60 comments
57.0k users