RegEx FTW solution in Clear category for First Word by leggewie
# findall returns a list of all the matches so we need to append  to return only the first
# \b matches a word boundary
# [\w'] matches any word character or '
# [\w']+ is a greedy match for an uninterrupted sequence of word characters or '
def first_word(text: str) -> str:
returns the first word in a given text.
return re.findall(r"\b[\w']+\b", text)
May 23, 2021