Advertisement
Guest User

Untitled

a guest
May 17th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. import re
  2.  
  3. if __name__ == '__main__':
  4.     ayy_reg = re.compile(r'^ayy\n?$')
  5.     lmao_reg = re.compile(r'^(lmao\d)\n?$')
  6.  
  7.     with open('./dd', 'r+') as out:
  8.         lines = out.readlines()
  9.         out.truncate(0)
  10.         out.seek(0)
  11.  
  12.         was_ayy = False
  13.         for line in lines:
  14.             if ayy_reg.findall(line):
  15.                 was_ayy = True
  16.  
  17.             elif lmao_reg.findall(line):
  18.                 if was_ayy:
  19.                     line = re.sub(lmao_reg, r'ehh(\1)\n', line)
  20.  
  21.             else:
  22.                 was_ayy = False
  23.  
  24.             out.write(line)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement