title: Trying to understand Python Regex's
body: <p>I am trying to write a Python regex to capture the full name of someone whose last name is Nakamoto? You can assume that the first name that comes before it will always be one word that begins with a capital letter. The regex must match the following:</p>
  
  <pre><code>'Satoshi Nakamoto'
  'Alice Nakamoto'
  'RoboCop Nakamoto'
  </code></pre>
  
  <p>but not the following:</p>
  
  <pre><code>'satoshi Nakamoto' (where the first name is not capitalised)
  'Mr. Nakamoto' (where the preceding word has a nonletter character)
  'Nakamoto' (which has no first name)
  'Satoshi nakamoto' (where Nakamoto is not capitalised)
  </code></pre>
  
  <p>I have used the following regex: <code>[A-Z][a-z]+\sNakamoto</code></p>
  
  <p>However this captures both <code>Satoshi Nakamoto</code> and <code>satoshi Nakamoto</code>. I would like to understand where I am going wrong and how to correct it. Here is my code:</p>
  
  <pre><code>import re    #import regular expressions
  
  #regular expression
  NameSearch = re.compile(r'[A-Z][a-z]+\sNakamoto', re.I | re.VERBOSE)
  
  # perform search on string
  Result = NameSearch.search("Satoshi Nakamoto")
  
  #Debug code to check if it found a match or not
  print (Result == None)
  
  if Result != None:
      print (Result.group())
  </code></pre>