Created
April 20, 2018 15:58
-
-
Save naranjja/8c4d628e5dd640bdf1e759636912fb9d to your computer and use it in GitHub Desktop.
A way to make string replacements upon regular expression matches.
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
import re | |
strings = [ | |
'/i wish this were html and not markdown.md', | |
'/yeah/me/too.md' | |
] | |
for s in strings: | |
print(re.sub(r'\/(.+).md', r'\1.html', s)) | |
# /i wish this were html and not markdown.html | |
# /yeah/me/too.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment