regex scanner question

Roman Suzi rnd at onego.ru
Wed Jun 27 09:55:57 EDT 2001


On 27 Jun 2001, Michael Hudson wrote:

> ... as here.  It's my understanding that these features are
> experimental, possibly buggy and certainly not documented.
> 
> OTOH, if you (or anyone else) think they're useful, can get them to
> work and (especially) write some docs, there's every chance thay will
> become a standard feature.

Good proposal!
 
> [...]
> > Is it standard Python feature I could safely use or will it be dropped
> > soon as it happened to xrange as a sequence type?
> 
> It might get binned if noone makes use of it.  But if there's a move
> to get rid of it, I'm sure it would be preceded by a "is anyone using
> sre.scanner?" query.

Probably I need to look at the source for comments..

> 
> > Could use of .scanner be recommended or not recommended?
> 
> If it solves your problem, I'd recommend it.  They're not going to go
> away before 2.2, you can be sure <wink>.

Of course it solves! It allows to search for matches one at a time.

The problem is that I think in 2.3 probably regex will be
rewritten again to adopt iterators/generators...
 
> > BTW, generators could be very useful if applied inside regex routines.
> > They will make it easy to hop from ane finding to another without taking
> > too much memory.
> 
> Example?

text = """ 1 2 ..... dfsdfds 234 dfs324234 """"

r = re.compile("\d+")

for match in r.matches(text):   # <<< allmatches is a generator
  print match.group()
  ...




Sincerely yours, Roman A.Suzi
-- 
 - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru -
 





More information about the Python-list mailing list