title: re.sub for replacing block(multi line) of text in python
body: <p>I am trying to replace a block of text which is spanning over multiple lines of text file using python. Here is how my input file looks like.</p>
  
  <p>input.txt:</p>
  
  <pre><code>ABCD abcd (
    . X (x),
     .Y (y)
  );
  ABCD1 abcd1 (
    . X1 (x1),
     .Y1 (y1)
  );
  </code></pre>
  
  <p>I am reading the above file with the below code and trying to replace the text but failed to do so. Below is my code.</p>
  
  <pre><code>fo = open(input.txt, 'r')
  input_str = fo.read()
  find_str = '''ABCD abcd (
        .X (x),
        .Y (y)
       );'''
  
  replace_str = '''ABCDE abcde (
        . XX (xx),
        .YY (yy)
        );'''
  
  input_str = re.sub(find_str, replace_str, input_str)
  </code></pre>
  
  <p>But the input_str seems to be unchanged. Not sure what am I missing. Any clues?</p>