This should be easy and this regex works fine to search for words beginning with specific characters, but I can't get it to match hashes and question marks.
This works and matches words beginning a:
r = re.compile(r"\b([a])(\w+)\b")
But these don't match: Tried:
r = re.compile(r"\b([#?])(\w+)\b")
r = re.compile(r"\b([\#\?])(\w+)\b")
r = re.compile( r"([#\?][\w]+)?")
even tried just matching hashes
r = re.compile( r"([#][\w]+)?"
r = re.compile( r"([/#][\w]+)?"
text = "this is one #tag and this is ?another tag"
items = r.findall(text)
expecting to get:
[('#', 'tag'), ('?', 'another')]