Re: [Pyparsing] How do you look ahead to the next character?
Brought to you by:
ptmcg
From: Kenneth L. <ke...@lo...> - 2012-08-14 13:28:06
|
On Mon, Aug 13, 2012 at 10:15 AM, Kenneth Loafman <ke...@lo...>wrote: > HI, > > I've got a grammar which checks a search query to see if it is valid. The > problem is that the grammar is allowing through items like 'foo:bar' as > 'foo AND bar' (implicit AND). Is there a way to check that a Regex has > parsed the entire term, i.e. that the next char is a space or EOL, and fail > if not? > > I've tried '(?=$|\s)' as a positive lookahead, but that always matches. > Never mind. I needed what amounts to a negative lookahead assertion in the grammar. I was thinking one level too low. So, the new term grammar would just be 'grammar + ~other_stuff'. ...Ken |