On Fri, Nov 4, 2011 at 3:42 PM, Joe Batt <joeb...@hotmail.co.uk> wrote:
> 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 re > > regexp=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 > > > > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > > You should read a little more about regular expressions to simplify yours, but I believe your problem is that you have no closing " after this: r"[a-z]) change it to r"[a-z]") -- Joel Goldstick
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor