Skip to content

Instantly share code, notes, and snippets.

@fatlotus
Created March 5, 2013 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fatlotus/5094575 to your computer and use it in GitHub Desktop.
Save fatlotus/5094575 to your computer and use it in GitHub Desktop.
Regular Expressions bug (feature?) in Python
$ python
Python 2.7.3 (default, Sep 26 2012, 21:51:14)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mmap
>>> import re
>>> fp = open('enwiki-latest-pages-articles.xml', 'rb')
>>> buf = mmap.mmap(fp.fileno(), 0, access = mmap.ACCESS_READ)
>>> rx = re.compile('a')
>>> rx.search(buf, (1 << 31) - 1).end()
-2147483639
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment