Firstly, a huge thanks to all for the solutions! Just what I was looking for.
> (Aside: why are you doing a case-insensitive match for a non-letter? Are > there different upper- and lower-case dollar signs?) As you can probably imagine, I had simplified the problem slightly, the language uses a couple of different introducers and also uses both numbers and letters (but only single characters). I was going to go with a similar idea of parsing per line but was trying to give RE another chance. I've used RE often in the past but for some reason this one had got under my skin. I found this to be quite an interesting little tool: http://www.gskinner.com/RegExr/ Martin -- http://mail.python.org/mailman/listinfo/python-list