Advertisement
zero_shubham1

regex module

Oct 16th, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.31 KB | None | 0 0
  1. >>> bool(re.search(r'(?:(x)|y)(?(1)y|x)', 'xy'))
  2. True
  3. >>> bool(re.search(r'(?:(x)|y)(?(1)y|x)', 'xx'))
  4. False
  5.  
  6. _______________________________________________________________
  7.  
  8.  
  9. having problem with "(?(id/name)y|x)". as per definition - conditional match of regex. y if group with given id or name exists else x.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement