title: Can you spot the problem with this REGEX statement?
body: <p>Im running .txt files through a <code>for</code> loop which should slice out keywords and <code>.append</code> them into lists. For some reason my REGEX statements are returning really odd results. </p>
  
  <p>My first statement which iterates through the full filenames and slices out the keyword works well.</p>
  
  <pre class="lang-py prettyprint-override"><code># Creates a workflow list of file names within target directory for further iteration
  stack = os.listdir(
    "/Users/me/Documents/software_development/my_python_code/random/countries"
  )
  
  # declares list, to be filled, and their associated regular expression,       to be used,
  # in the primary loop
  names = []
  name_pattern = r"-\s(.*)\.txt"
  
  # PRIMARY LOOP
  for entry in stack:
    if entry == ".DS_Store":
      continue
  
  # extraction of country name from file name into `names` list
    name_match = re.search(name_pattern, entry)
    name = name_match.group(1)
    names.append(name)
  </code></pre>
  
  <p>This works fine and creates the list that I expect</p>
  
  <p>However, once I move on to a similar process with the actual contents of files, it no longer works.</p>
  
  <pre><code>religions = []
  reli_pattern = r"religion\s=\s(.+)."
  
  # PRIMARY LOOP
  for entry in stack:
    if entry == ".DS_Store":
      continue
  # opens and reads file within `contents` variable
    file_path = (
    "/Users/me/Documents/software_development/my_python_code/random/countries" + "/" + entry
    )
    selection = open(file_path, "rb")
    contents = str(selection.read())
  
  # extraction of religion type and placement into `religions` list
    reli_match = re.search(reli_pattern, contents)
    religion = reli_match.group(1)
    religions.append(religion)
  </code></pre>
  
  <p>The results should be something like: <code>"therevada", "catholic", "sunni"</code> etc.
  Instead i'm getting seemingly random pieces of text from the document which have nothing to do with my <code>REGEX</code> like ruler names and stat values that do not contain the word <code>"religion"</code>
  To try and figure this out I isolated some of the code in the following way: </p>
  
  <pre class="lang-py prettyprint-override"><code>contents = "religion = catholic"
  reli_pattern = r"religion\s=\s(.*)\s"
  
  reli_match = re.search(reli_pattern, contents)
  
  print(reli_match)
  </code></pre>
  
  <p>And <code>None</code> is printed to the console so I am assuming the problem is with my <code>REGEX</code>. What silly mistake am I making which is causing this?</p>