[Tutor] Regular expression on python

Alan Gauld alan.gauld at btinternet.com
Mon Apr 13 21:14:16 CEST 2015


On 13/04/15 19:42, Alan Gauld wrote:

>>          if lines.startswith("Input"):
>>              tp = lines.split("\t")
>>              print re.findall("Input\d",str(tp))
>
> Input is not followed by a number. You need a more powerful pattern.
> Which is why I recommend trying to solve it as far as possible
> without using regex.

I also just realised that you call split there then take the str() of 
the result. That means you are searching the string representation
of a list, which doesn't seem to make much sense?


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list