[Solved] Python regex not printing contents in new list


You are looping over individual characters, not over lines:

>>> maxline="i have a Prof.John and As Maria a bike"
>>> for line in maxline:
...     print line
... 
i

h
a
v
e
# .... etc.

These individual characters don’t match your expressions.

Change maxline to be a list; perhaps by splitting it on newlines with str.splitlines():

for line in maxline.splitlines():

and printing out a, not res:

    print a

1

solved Python regex not printing contents in new list