Is there any way to use regex match on a stream in python? like
reg = re.compile(r\'\\w+\')
reg.match(StringIO.StringIO(\'aa aaa aa\'))
And
This seems to be an old problem. As I have posted to a a similar question, you may want to subclass the Matcher class of my solution streamsearch-py and perform regex matching in the buffer. Check out the kmp_example.py for a template. If it turns out classic Knuth-Morris-Pratt matching is all you need, then your problem would be solved right now with this little open source library :-)