Last active
December 10, 2015 09:29
-
-
Save LK64076007A/4414475 to your computer and use it in GitHub Desktop.
Added multiline regex flag.
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 clipboard, console, re | |
mytext = clipboard.get() | |
# User input text | |
matchedText = console.input_alert("Find", "Enter text/regex to find.") | |
replacedText = console.input_alert("Replace", "Enter text to replace.") | |
# Regex find and replace | |
mytext = re.sub(matchedText, replacedText, mytext, flags=re.MULTILINE) | |
# Displays new text; comment out if you don't care | |
# Mostly useful for testing | |
console.clear() | |
print mytext | |
# Sends new text back to clipboard for pasting | |
clipboard.set(mytext) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment