Advertisement
Guest User

Untitled

a guest
Apr 12th, 2013
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. import re
  2.  
  3. sample = [
  4.     'blah',
  5.     'food',
  6.     'test',
  7.     'junk',
  8.     'bazfool',
  9.     'bark',
  10.     'fodder']
  11.  
  12. def process(input):
  13.     i = 0
  14.     input_length = len(input)
  15.     pattern = '.*foo.*'
  16.     while (i < input_length):
  17.         if re.match(pattern, input[i]) and i < (input_length - 1):
  18.             yield input[i + 1]
  19.             i += 2
  20.         else:
  21.             i += 1
  22.  
  23. for res in process(sample):
  24.     print(res)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement