regex searching hangs
Jan Erik Breimo
janeb at broadpark.no
Sun Feb 8 12:04:36 EST 2004
More information about the Python-list mailing list
Sun Feb 8 12:04:36 EST 2004
- Previous message (by thread): regex searching hangs
- Next message (by thread): regex searching hangs
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Fortepianissimo" <fortepianissimo at yahoo.com.tw> wrote in message news:ef08387c.0402080729.621632ca at posting.google.com... > Could someone explains why the following code hangs (Python 2.3.3)? > > --- CODE STARTS --- > import re > > p=re.compile(r'\S+(?:\.\S+)+\.com') > > t='......................................' > p.search(t) > --- CODE ENDS --- > The search doesn't hang, it just takes a long time to compute - the time it takes almost doubles for each dot you add to t. If you replace \S in the expression with [^ \t\n\r\f\v.] (ie. no whitespace and no dots) you'll get the computation time you expect.
- Previous message (by thread): regex searching hangs
- Next message (by thread): regex searching hangs
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list