So what i am trying to do is to have an input field named a. Then have a line of regex which checks a for 'i am (something)' (note something could be a chain of words.) and then prints How long have you been (something)?
This is my code so far:
if re.findall(r"i am", a):
print('How long have you been {}'.format(re.findall(r"i am", a)))
But this returns me a list of [i, am] not the (something). How do i get it to return me (something?)
Thanks,
A n00b at Python
Do you mean something like this?
r'I am (.*?)$'
matchesI am
and then everything else to the end of the string.To match one word after, you can do: