Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #1/usr/bin/env python
- # this is from The Python
- # Standard Library by example
- # ISBN13: 9780321767349
- import mmap
- import re
- import contextlib
- pattern = re.compile(r'(\.\W+)?([^.]?nulla[^.]*?\.)',
- re.DOTALL | re.IGNORECASE | re.MULTILINE)
- with open('lorem.txt', 'r') as f:
- with contextlib.closing(mmap.mmap(f.fileno(), 0,
- access=mmap.ACCESS_READ)
- ) as m:
- for match in pattern.findall(m):
- print match[1].replace('\n', ' ')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement