title: Parsing a ddl in Python with regex using re
body: <p>I'm trying to remove temporary tables from a ddl of over 100 tables by parsing through a file using python and regex. I managed to get the result I want using <code>'_TMP' in line</code>, but I desperately want to achieve this with regex. I was having trouble figuring out how to parse over multiple lines, which is impossible if your iterating line by line right?</p>
  
  <p>Example DDL:</p>
  
  <pre><code>CREATE TABLE EXNAME.EXTABLE_TMP (
      CONTRIBUTOR_ID VARCHAR2(32) NOT NULL,
      AFFILIATION_TYPE VARCHAR2(10) NOT NULL,
      SEQ_NUMBER NUMBER(2) NOT NULL,
      PRIMARY KEY (CONTRIBUTOR_ID,AFFILIATION_TYPE,SEQ_NUMBER)
  );
  
  CREATE TABLE EXNAME.EXTABLE (
      CONTRIBUTOR_ID VARCHAR2(32) NOT NULL,
      AFFILIATION_TYPE VARCHAR2(10) NOT NULL,
      SEQ_NUMBER NUMBER(2) NOT NULL,
      PRIMARY KEY (CONTRIBUTOR_ID,AFFILIATION_TYPE,SEQ_NUMBER)
  );
  </code></pre>
  
  <p>My current solution:</p>
  
  <pre><code>f.open('/path/to/file.txt')
  copy.open('/path/to/fileCopy.txt')
  
  tmpFound = False
  
  for line in f:
      if '_TMP' in line:
          tmpFound = True
      elif tmpFound == True and ';' in line:
          tmpFound = False
          continue
      if not tmpFound:
         print(line)
         copy.write(line)
  
  f.close()
  copy.close()
  </code></pre>