Monday, 26 August 2013

Grabbing a part of a string using regex in python 3.x

Grabbing a part of a string using regex in python 3.x

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 ' (note something could be a chain
of words.) and then prints How long have you been ?
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 . How do i get it to return me
Thanks,
A n00b at Python

No comments:

Post a Comment