[Licheng Fang] > ... > I want to know if there is some way to make Python RE behave like grep > does,
Not in general, no. The matching strategies couldn't be more different, and that's both deep and intentional. See Friedl's book for details: http://regex.info/ > or do I have to change to another engine? Yes, if POSIX regexp semantics are what you require. Several years ago there was an extension module for Python supplying POSIX semantics, but I couldn't find anything current just now in a minute of searching. You may be more motivated to search longer ;-) -- http://mail.python.org/mailman/listinfo/python-list