Skip to content

Instantly share code, notes, and snippets.

@david-botelho-mariano
Last active October 2, 2022 14:58
Show Gist options
  • Save david-botelho-mariano/231d028b3b18cb3abb31c36f81e56838 to your computer and use it in GitHub Desktop.
Save david-botelho-mariano/231d028b3b18cb3abb31c36f81e56838 to your computer and use it in GitHub Desktop.
remove @username from string using python and regex
# https://www.datasnips.com/59/remove-usernames-http-links-from-tweet-data/
# https://openclassrooms.com/en/courses/6532301-introduction-to-natural-language-processing/6980751-extract-information-with-regular-expression
import re
texto = """
1
2
aa @john bbb
3
@mary
4
"""
transf = re.sub(r'@[^ ]+', '', texto)
print(transf)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment