Created
August 30, 2012 22:43
-
-
Save shawnjgoff/3543601 to your computer and use it in GitHub Desktop.
replace python's depricated dict.has_key(k) with "k in dict" with a regex
This file contains 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
Vim regex | |
:%s/\([^ ]\+\)\.has_key(\(.\{-}\))/\2 in \1/g | |
sed regex | |
s/\([^ ]\+\)\.has_key(\([^)]*\))/\2 in \1/g | |
And here is the string.method(object, ...) -> object.method(...) | |
Specificlaly for string.replace(): | |
Vim regex: | |
%s/string\.replace(\(.\{-}\), /\1.replace(/ | |
sed regex: | |
s/string\.replace(\([^,]*\), /\1.replace(/ | |
string.method(object) -> object.method() | |
Specifically for string.lower(): | |
sed regex: | |
s/string\.lower(\(.*\))/\1.lower()/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment