I'm trying to match, last letter in string 'onlin' as any and then replace it if it matches with word offline. No luck. Please give advice, cheers.
import mitmproxy
import re
def response(flow):
old = b'Onlin\w{1}'
new = b'Offline'
flow.response.content = flow.response.content.replace(old, new)
I guess you are using the wrong function for replacement. Try re.sub
.
def response(flow):
old = b'Onlin\w'
new = b'Offline'
# https://docs.python.org/3/library/re.html#re.sub
flow.response.content = re.sub(old, new, flow.response.content)