title: Python 3.10 pattern matching (PEP 634) - wildcard in string
body: <p>I got a large list of JSON objects that I want to parse depending on the start of one of the keys, and just wildcard the rest. A lot of the keys are similar, like <code>&quot;matchme-foo&quot;</code> and <code>&quot;matchme-bar&quot;</code>. There is a builtin wildcard, but it is only used for whole values, kinda like an <code>else</code>.</p>
  <p>I might be overlooking something but I can't find a solution anywhere in the proposal:</p>
  <p><a href="https://docs.python.org/3/whatsnew/3.10.html#pep-634-structural-pattern-matching" rel="noreferrer">https://docs.python.org/3/whatsnew/3.10.html#pep-634-structural-pattern-matching</a></p>
  <p>Also a bit more about it in PEP-636:</p>
  <p><a href="https://www.python.org/dev/peps/pep-0636/#going-to-the-cloud-mappings" rel="noreferrer">https://www.python.org/dev/peps/pep-0636/#going-to-the-cloud-mappings</a></p>
  <p>My data looks like this:</p>
  <pre><code>data = [{
            &quot;id&quot;     : &quot;matchme-foo&quot;,
            &quot;message&quot;: &quot;hallo this is a message&quot;,
        },{
            &quot;id&quot;     : &quot;matchme-bar&quot;,
            &quot;message&quot;: &quot;goodbye&quot;,
        },{
            &quot;id&quot;     : &quot;anotherid&quot;,
            &quot;message&quot;: &quot;completely diffrent event&quot;
        }, ...]
  </code></pre>
  <p>I want to do something that can match the id without having to make a long list of <code>|</code>'s.</p>
  <p>Something like this:</p>
  <pre><code>for event in data:
      match event:
          case {'id':'matchme-*'}: # Match all 'matchme-' no matter what comes next
              log.INFO(event['message'])
          case {'id':'anotherid'}:
              log.ERROR(event['message'])
  </code></pre>
  <p>It's a relatively new addition to Python so there aren't many guides on how to use it yet.</p>