Stephen J. Turnbull wrote:
I think this is a pretty unconvincing example. While people seem to love to hate on regular expressions, it's hard to see how that beats def unquote(string: str) -> str: m = re.match(r"^(?:"(.*)"|'(.*)'|(?Pvalue3))$", string)
RegEx feels overkill for this. Certainly takes longer to read, understand and test. Here's a more convincing example, let's build an imaginary data format parser: ```python data = '''\ scores: - Matthew: 100 - David: 90 groceries: - spam: 3 - eggs: 12 ''' parsed = {} for line in data.splitlines(): match line: case f"{heading}:" parsed[heading] = {} case f"- {name}: {count}": parsed[heading][name] = int(count) print(parsed) # Gives {'scores': {'Matthew': 100, 'David': 90}, 'groceries': {'spam': 3, 'eggs': 12}} ```