the text input is something like this
West Team 4, Eastern 3\n
-------Update--------
the input is a txt file containing team name and scores like a football game the whole text file will be something like this, two names and scores:
West Team 4, Eastern 5
Nott Team 2, Eastern 3
West wood 1, Eathan 2
West Team 4, Eas 5
I am using with open to read file line by line therefore there will be \n at the end of the line.
I would like to extract this line of text in to something like:
['West Team', 'Eastern']
What I currently have in mind is to use regex
result = re.sub("[\n^\s$\d]", "", text).split(",")
this code results in this:
['WestTeam','Eastern']
I'm sure that my regex is not correct. I want to remove '\n' and any number including the space in front of the number but not the space in the middle of the name.
Open to any suggestion that to achieve this result, doesn't necessarily use regex.
re.findall(r',?\s*(\D*[^\d\s])', text)?