On Mon, Feb 2, 2009 at 5:46 PM, Bernard Rankin <beranki...@yahoo.com> wrote: > Hello, > > > I'd like to match any line that does not start with FOO. (Using just a > reg-ex rule) > > 1) What is the effective difference between: > > (?!^FOO).* > > ^(?!FOO).*
One difference is that the first will match starting anywhere in a string, while the second will match only at the start. For this exact example I don't think it matters but if you replace .* with something else you can see a difference. For example: In [52]: re.findall('(?!^FOO) in', 'in in in') Out[52]: [' in', ' in'] In [53]: re.findall('^(?!FOO) in', 'in in in') Out[53]: [] I think I would use the second form, it seems to more directly express what you mean. Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor