Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- if __name__ == '__main__':
- ayy_reg = re.compile(r'^ayy\n?$')
- lmao_reg = re.compile(r'^(lmao\d)\n?$')
- with open('./dd', 'r+') as out:
- lines = out.readlines()
- out.truncate(0)
- out.seek(0)
- was_ayy = False
- for line in lines:
- if ayy_reg.findall(line):
- was_ayy = True
- elif lmao_reg.findall(line):
- if was_ayy:
- line = re.sub(lmao_reg, r'ehh(\1)\n', line)
- else:
- was_ayy = False
- out.write(line)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement