title: How to remove parentheses and all data within using Python3
body: <p>I'm trying to remove parenthesis and all data within using Python 3.  </p>
  
  <p>I've looked into several different threads, including here: </p>
  
  <p><a href="https://stackoverflow.com/questions/20894525/how-to-remove-parentheses-and-all-data-within-using-pandas-python">How to remove parentheses and all data within using Pandas/Python?</a></p>
  
  <p>After finally getting: </p>
  
  <pre><code>re.sub(r"\(.*\)|\s-\s.*", r"", str1)
  </code></pre>
  
  <p>to run without errors, it didn't remove the content from the str1 string.</p>
  
  <p>Then I tried this approach:</p>
  
  <p><a href="https://stackoverflow.com/questions/47997659/how-to-remove-text-within-parentheses-from-python-string">How to remove text within parentheses from Python string?</a></p>
  
  <p>to remove the parenthesis and contents from the file before reading it in and storing to str1 - 
  but I get this error:</p>
  
  <pre><code>Traceback (most recent call last):
  
    File "sum_all.py", line 27, in &lt;module&gt;
      data.append(line.replace(match.group(),'').strip())
  AttributeError: 'NoneType' object has no attribute 'group'
  </code></pre>
  
  <p>Here is the code, I'm obviously new at this and appreciate any help!!</p>
  
  <pre><code># Python3 program to calculate sum of 
  # all numbers present in a str1ing 
  # containing alphanumeric characters 
  
  # Function to calculate sum of all 
  # numbers present in a str1ing 
  # containing alphanumeric characters 
  import re
  import math
  import pyperclip
  import pandas
  def find_sum(str1): 
      # Regular Expression that matches digits in between a string 
      return sum(map(int,re.findall('\d+',str1))) 
  
  def find_sum2(str2): 
      # Regular Expression that matches digits where hr follows short for hours 
      return sum(map(int,re.findall('(\d+)hr',str1)))
  
  str2=0
  
  # Regular Expression 
  data=[]
  pattern=r'\(.+\)|\s\-.+'
  with open('project.txt','r') as f:
      for line in f:
          match=re.search(pattern,line)
          data.append(line.replace(match.group(),'').strip())
  
  print(data)
  
  # input alphanumeric str1ing 
  with open ("project.txt", "r") as myfile:
      str1=myfile.read().replace('\n', '')
  
  
  # Regular Expression that removes (*) and Normalizes White Space - didn't work
  #re.sub(r"\(.*\)|\s-\s.*", r"", str1)
  
  # Regular Expression that removes (*) - didn't work
  #re.sub(r"\(.*\)", r"", str1)
  
  </code></pre>