Skip to content

Instantly share code, notes, and snippets.

@bootandy
Created July 11, 2012 10:01
Show Gist options
  • Save bootandy/3089398 to your computer and use it in GitHub Desktop.
Save bootandy/3089398 to your computer and use it in GitHub Desktop.
Python string basics
""" 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