title: Regex find non digit and/or end of string
body: <p>How do I include an end-of-string and one non-digit characters in a python 2.6 regular expression set for searching?</p>
  
  <p>I want to find 10-digit numbers with a non-digit at the beginning and a non-digit or end-of-string at the end. It is a 10-digit ISBN number and 'X' is valid for the final digit.</p>
  
  <p>The following do not work:</p>
  
  <pre><code>is10 = re.compile(r'\D(\d{9}[\d|X|x])[$|\D]')
  is10 = re.compile(r'\D(\d{9}[\d|X|x])[\$|\D]')
  is10 = re.compile(r'\D(\d{9}[\d|X|x])[\Z|\D]')
  </code></pre>
  
  <p>The problem arises with the last set: [\$|\D] to match a non-digit or end-of-string.</p>
  
  <p>Test with:</p>
  
  <pre><code>line = "abcd0123456789"
  m = is10.search(line)
  print m.group(1)
  
  line = "abcd0123456789efg"
  m = is10.search(line)
  print m.group(1)
  </code></pre>