Python: Perform a regex replace
30 October 2022 (Updated 24 September 2023)
Syntax:
re.sub(search_pattern, replacement, subject, count=0)
Example:
import re
>>> re.sub("[a-z]", "*", "foobar123")
'******123'
Sources
Tagged:
Python
Thanks for your comment 🙏. Once it's approved, it will appear here.
Leave a comment