Regular Expression
patrick.waldo at gmail.com
patrick.waldo at gmail.com
Mon Oct 22 18:29:38 EDT 2007
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)
More information about the Python-list
mailing list