python - Regex for hashtags prints out each letter -
i want find hashtags in tweets. code below finds hashtags, when printing them out each letter written out instead of actual hashtag.
the thing want create links found hashtags isn't possible because should create links each letter in hashtags.
what doing wrong?
tag_regex = re.compile(r""" [/^#\s+$/] """, re.verbose) tag in tag_regex.findall(tweet): print tag
outcome:
# h s h t g 1 # h s h t g 2
the brackets construct character class don't want. also, don't want use regex delimiters /.../
in language doesn't use them (a simple string sufficient, preferably raw string don't need escape backslashes). finally, shouldn't use anchors if want find substrings of input string:
tag_regex = re.compile(r"#\s+")
Comments
Post a Comment