regexp partial matching, or hitEnd

2012-04-05 Thread Константин Куликов
I want something like this in python :

http://stackoverflow.com/questions/2526756/can-java-util-regex-pattern-do-partia...http://stackoverflow.com/questions/2526756/can-java-util-regex-pattern-do-partial-matches

First you have to call one of the standard methods to apply the regex,
like matches() or find().
If that returns false, you can use the hitEnd() method to find out if some
longer string could have matched:
String[] inputs = { AA, BB };
Pattern p = Pattern.compile(AB);
Matcher m = p.matcher();
for (String s : inputs)
{
  m.reset(s);
  System.out.printf(%s -- full match: %B; partial match: %B%n,
s, m.matches(), m.hitEnd());
}

output:
AA -- full match: FALSE; partial match: TRUE
BB -- full match: FALSE; partial match: FALSE

So. Is there already some function like hitEnd() in any python regexp
library?
Or if not, maybe it's could be added in the feature to the standart re
module? :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: regexp partial matching, or hitEnd

2012-04-05 Thread Mark Lawrence

On 05/04/2012 08:29, Константин Куликов wrote:

I want something like this in python :

http://stackoverflow.com/questions/2526756/can-java-util-regex-pattern-do-partia...http://stackoverflow.com/questions/2526756/can-java-util-regex-pattern-do-partial-matches

First you have to call one of the standard methods to apply the regex,
like matches() or find().
If that returns false, you can use the hitEnd() method to find out if some
longer string could have matched:


Dark satanic writing snipped :)


So. Is there already some function like hitEnd() in any python regexp
library?
Or if not, maybe it's could be added in the feature to the standart re
module? :)



More likely to go into the new regex module that's on pypi.  Talking of 
which is this going into Python 3.3, I see it's mentioned in PEP398 but 
can't find any mention in the Python 3.3 What's New docs, or have I 
simply missed something?


--
Cheers.

Mark Lawrence.

--
http://mail.python.org/mailman/listinfo/python-list


Re: regexp partial matching, or hitEnd

2012-04-05 Thread Terry Reedy

On 4/5/2012 8:19 AM, Mark Lawrence wrote:


More likely to go into the new regex module that's on pypi. Talking of
which is this going into Python 3.3, I see it's mentioned in PEP398 but
can't find any mention in the Python 3.3 What's New docs, or have I
simply missed something?


I think it has been approved in principle, but still needs some people 
to do something to actually make it happen.


--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list