From: Eric B. <er...@go...> - 2007-03-12 21:47:49
|
"Jason Wei [ES]" <ja...@ei...> wrote: > I created an RX_PCRE_REGULAR_EXPRESSION object for regular expression > matching. > And I have setup options I need. > > I used it to do a first match using keyword *"a*"*, I got the right result. > I used it to do a second match using keyword *"^a*"*, I got the right > result again. (Of course, I called `compile (keyword)' everytime). > Now I used it to do a third match using the keyword *"a*"* again over > the same context, then I got different result from the first match. > > During these three tries, I don't change any options, so I think I don't > need to call `reset'. But even if I called `reset' every time, I got > different results. > > And I provided a small application to show this problem. Just run this > application which check enabled and observe the assertion violation. > > It there anything else that I need to do to make it work? There are two ways to tell the regexp to match from the start: either put the character '^' at the beginning of the regexp: regexp.compile ("^a*") or set the option `is_anchored': regexp.set_anchored (True) regexp.compile ("a*") In both cases `is_anchored' is set to True. If later on you want the regexp to match anywhere in the string, you have to unset `is_anchored': regexp.set_anchored (False) regexp.compile ("a*") So, in your example: l_filter := filter_engine l_filter.set_anchored (False) l_filter.reset l_filter.compile (a_keyword) -- Eric Bezault mailto:er...@go... http://www.gobosoft.com |