← Back to challenges

RegEx swapcase()

PythonHardregexstrings

Instructions

Define a match and a repl to create a swapcase() method.

Examples

re.sub(match, repl, "hello") ➞ "HELLO"

re.sub(match, repl, "wOw|WoW") ➞ "WoW|wOw"
# Special characters are left alone.

Notes

N/A

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.