Created
July 11, 2012 10:01
-
-
Save bootandy/3089398 to your computer and use it in GitHub Desktop.
Python string basics
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
""" looks for the string: '@user ' in the string message and removes all occurrences""" | |
def remove_user_from_message(msg, user): | |
p = re.compile('@'+user+'\s+') | |
return p.subn('', msg)[0] | |
""" | |
indexOf and substring are done like this: | |
index_of = find | |
s.substring(1,5) = s[1:5] | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment