A very basic question but how do I extract the last word (politics) from the string, and do so in a function? For now I have this (it works well with one string but when I put it in a function and feed it a lot of lines of code it stops working):
string = '''twitmo20 || Tue Jul 07 19:19:40 +0000 2020 || Imagine you are a Democratic and were told that COVID is a Bioweapon used on the people in another attempt to destr… || 0.7716583196 || politics\n
def function(input):
categories = re.findall(r"(?:.+\s\|\|\s){4}(.+)\n", str(input))
return categories
source https://stackoverflow.com/questions/69328641/using-regex-functions
Comments
Post a Comment