title: Python: check if string meets specific format
body: <p>Programming in Python3.</p>
  
  <p>I am having difficulty in controlling whether a string meets a specific format.</p>
  
  <p>So, I know that Python does not have a <code>.contain()</code> method like Java but that we can use regex.
  My code hence will probably look something like this, where lowpan_headers is a dictionary with a field that is a string that should meet a specific format.
  So the code will probably be like this:</p>
  
  <pre><code>import re
  
  lowpan_headers = self.converter.lowpan_string_to_headers(lowpan_string)
  pattern = re.compile("^([A-Z][0-9]+)+$")
  pattern.match(lowpan_headers[dest_addrS])
  </code></pre>
  
  <p>However, my issue is in the format and I have not been able to get it right.
  The format should be like <code>bbbb00000000000000170d0000306fb6</code>, where the first 4 characters should be <code>bbbb</code> and all the rest, with that exact length, should be hexadecimal values (so from 0-9 and a-f).</p>
  
  <p>So two questions:
  (1) any easier way of doing this except through importing re 
  (2) If not, can you help me out with the regex?</p>