title: Parse a string with key expressions
body: <p>I'm trying to parse strings that have this format:</p>
  <pre><code>sample = '&lt;STATUS=&quot;OK&quot; VERSION=&quot;B&quot; MESSAGE=&quot;Connected in demo mode&quot;&gt;&lt;timestamp=&quot;1602765370&quot; id=&quot;123&quot;&gt;'
  </code></pre>
  <p>so that given a key I can get the associated value, for example:</p>
  <pre><code>parser('STATUS', sample)  # 'OK'
  parser('MESSAGE', sample) # 'Connected in demo mode'
  </code></pre>
  <p>I've tried using re:</p>
  <pre><code>import re
  def parser(key, string):
      return re.search(f'(?&lt;={key}=)\S+', string).group()
  </code></pre>
  <p>but the results are <code>'&quot;OK&quot;'</code> for the first example and just <code>'&quot;Connected'</code> for the second. How can I avoid retrieving the quotes and get the full string associated for each value? thanks in advance.</p>