Mask multiple sensitive data using re.sub?
问题 I would like to mask several values in a string. This call works for a single value as expected. message = "my password=secure and my private_key=securekey should not be logged." message = re.sub(r"(?is)password=.+", "password=xxxx", str(message)) What does the regular expression have to look like so that I can mask multiple values from a dictionary? d = {"password": "xxxx", "private_key": "zzzz"} message = re.sub(r"(?is)\w=.+", lambda m: d.get(m.group(), m.group()), message) Is it also