Last active
December 25, 2022 22:03
-
-
Save jamescherti/981306ca16f92115a57796e1ae3d241d to your computer and use it in GitHub Desktop.
Escape all characters.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # License: MIT | |
| # Author: James Cherti | |
| # URL: https://gist.github.com/jamescherti/981306ca16f92115a57796e1ae3d241d | |
| """Escape all characters.""" | |
| import re | |
| def escape_all(string: str): | |
| """Escape all characters.""" | |
| return re.sub(r'(.)', r'\\\1', string) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment