You are viewing a single comment's thread. Return to all comments →
def replace(match: re.Match) -> str: token = match.group(0) if '&&' in token: return token.replace('&&', 'and') if '||' in token: return token.replace('||', 'or') print(f"Invalid match: {token}") N = int(input()) for _ in range(N): print(re.sub(r'(?<=\s)(&&|\|\|)(?=\s)', replace, input()))
Seems like cookies are disabled on this browser, please enable them to open this website
Regex Substitution
You are viewing a single comment's thread. Return to all comments →