[BangPypers] A trivial doubt in negative lookbehind regular expression pattern

Senthil Kumaran orsenthil at gmail.com
Tue Apr 5 16:30:07 CEST 2011


On Tue, Apr 05, 2011 at 06:21:03PM +0530, Neha Jain wrote:
> >
> but the problem with this is that the line where I am searching for may be
> like..  #define ABC_PG... so may be something for the start of the word type
> matching may help.. \b?? i am not sure..

The reason that second pattern is inclusive of the first one, makes it
bit tricky.  

You can also consider to do it two steps with splitting the words and
verify that simpler strings do not startswith 'ABC_' pattern.


>>> for each in re.split('\W','#define ABC_CDF\nAB_CDF'):
['', 'define', 'ABC_CDF', 'AB_CDF']

-- 
Senthil


More information about the BangPypers mailing list