[Tutor] Help with re in Python 3
Joe Batt
joebatt at hotmail.co.uk
Fri Nov 4 20:42:15 CET 2011
Hi all,Still trying with Python and programming in general….
I am trying to get a grip with re. I am writing a program to open a text file and scan it for exactly 3 uppercase letters in a row followed by a lowercase followed by exactly 3 uppercase letters. ( i.e. oooXXXoXXXooo )If possible could you explain why I am getting "EOL while scanning string literal" when I try running the following program in Python 3.
My program:
import reregexp=re.compile(r"[a-z]"r"[A-Z]"r"[A-Z]"r"[A-Z]"r"[a-z]"r"[A-Z]"r"[A-Z]"r"[A-Z]"r"[a-z]) file=('///Users/joebatt/Desktop/python3.txt','r')for line in file.readlines(): if regexp.search(line): print("Found value 3 caps followed by lower case followed by 3 caps")file.close()
If possible could you explain why I am getting "EOL while scanning string literal" when I try running my program in Python 3.
Thanks for your help
Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111104/36f6f358/attachment.html>
More information about the Tutor
mailing list