fork(2) download
  1. # http://stackoverflow.com/q/28353897/5290909
  2. import re
  3.  
  4. text = "A\nB"
  5. print("Text: '%s'\n---" % text)
  6. patterns = [ "a", "a(?i)", "A.*B", "A(?s).*B", "A.*(?s)B"]
  7.  
  8. for p in patterns:
  9. match = re.search( p, text)
  10. print("Pattern: '%s'\t\tMatch: %s" % (p, match.span() if match else None))
Success #stdin #stdout 0.02s 9936KB
stdin
Standard input is empty
stdout
Text: 'A
B'
---
Pattern: 'a'		Match: None
Pattern: 'a(?i)'		Match: (0, 1)
Pattern: 'A.*B'		Match: None
Pattern: 'A(?s).*B'		Match: (0, 3)
Pattern: 'A.*(?s)B'		Match: (0, 3)