On Oct 22, 5:29 pm, [EMAIL PROTECTED] wrote: > Hi, > > I'm trying to learn regular expressions, but I am having trouble with > this. I want to search a document that has mixed data; however, the > last line of every entry has something like C5H4N4O3 or CH5N3.ClH. > All of the letters are upper case and there will always be numbers and > possibly one . > > However below only gave me none. > > import os, codecs, re > > text = 'C:\\text_samples\\sample.txt' > text = codecs.open(text,'r','utf-8') > > test = re.compile('\u+\d+\.') > > for line in text: > print test.search(line)
If those are chemical symbols, then I guarantee that there will be lower case letters in the expression (like the "l" in "ClH"). -- Paul -- http://mail.python.org/mailman/listinfo/python-list