Advertisement
rfmonk

re_anchoring.py

Jan 2nd, 2014
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3.  
  4. from re_test_patterns import test_patterns
  5.  
  6. test_patterns(
  7.     'This is some text -- with punctuation.',
  8.     [(r'^\w+',      'word at start of string'),
  9.      (r'\A\w+',     'word at start of string'),
  10.      (r'\w+\S*$',   'word near end of string, skip punctuation'),
  11.      (r'\w+\S*\Z',  'word near end of string, skip punctuation'),
  12.      (r'\w*t\w*',   'word containing t'),
  13.      (r'\bt\w+',    't at start of word'),
  14.      (r'\w+t\b',    't at end of word'),
  15.      (r'\Bt\B',     't, not start or end of word'),
  16.      ])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement