regexp partial matching, or hitEnd
Константин Куликов
zxnotdead at gmail.com
Thu Apr 5 03:29:56 EDT 2012
More information about the Python-list mailing list
Thu Apr 5 03:29:56 EDT 2012
- Previous message (by thread): Cannot connect to IMAP server in Python 3.2
- Next message (by thread): regexp partial matching, or hitEnd
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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("AAAAAB"); 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? :) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-list/attachments/20120405/a5b4174f/attachment.html>
- Previous message (by thread): Cannot connect to IMAP server in Python 3.2
- Next message (by thread): regexp partial matching, or hitEnd
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list