Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- sample = [
- 'blah',
- 'food',
- 'test',
- 'junk',
- 'bazfool',
- 'bark',
- 'fodder']
- def process(input):
- i = 0
- input_length = len(input)
- pattern = '.*foo.*'
- while (i < input_length):
- if re.match(pattern, input[i]) and i < (input_length - 1):
- yield input[i + 1]
- i += 2
- else:
- i += 1
- for res in process(sample):
- print(res)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement