title: python get substring from regex
body: <p>I want to extract a substring from a string, which is conform to a certain regex. The regex is:</p>
  
  <p><code>(\[\s*(\d)+ byte(s)?\s*\](\s*|\d|[A-F]|[a-f])+)</code></p>
  
  <p>Which effectively means that all of these strings get accepted:</p>
  
  <pre><code>[4 bytes] 66 74 79 70 33 67 70 35
  [ 4 bytes ] 66 74 79 70 33 67 70 35
  [1 byte] 66 74 79 70 33 67 70 35
  </code></pre>
  
  <p>I want to extract only the amount of bytes (just the number) from this string. I thought of doing this with <code>re.search</code>, but I'm not sure if that will work. What would be the cleanest and most performant way of doing this?</p>