Skip to content

Instantly share code, notes, and snippets.

@LK64076007A
Last active December 10, 2015 09:29
Show Gist options
  • Save LK64076007A/4414475 to your computer and use it in GitHub Desktop.
Save LK64076007A/4414475 to your computer and use it in GitHub Desktop.
Added multiline regex flag.
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