Advertisement
rfmonk

re_flag_dotall.py

Jan 2nd, 2014
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3.  
  4. import re
  5.  
  6. text = 'This is some text -- with punctuation.\nA second line.'
  7. pattern = r'.+'
  8. no_newlines = re.compile(pattern)
  9. dotall = re.compile(pattern, re.DOTALL)
  10.  
  11. print 'Text:\n %r' % text
  12. print 'Pattern:\n %s' % pattern
  13. print 'No newlines :'
  14. for match in no_newlines.findall(text):
  15.     print ' %r' % match
  16. print 'Dotall      :'
  17. for match in dotall.findall(text):
  18.     print ' %r' % match
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement