title: Different way to specify matching new line in Python regex
body: <p>I find out there are different ways to match a new line in python regex. For example, all patterns used in the code below can match a new line</p>
  
  <pre><code>str = 'abc\n123'
  pattern = '\n'   # print outputs new line 
  pattern2 = '\\n' # print outputs \n
  pattern3 = '\\\n' # print outputs \ and new line
  pattern4 = r'\n'  # print outputs \n
  s = re.search(pattern, str).group()
  print ('a' + s + 'a')
  </code></pre>
  
  <p>I have 2 questions about this:</p>
  
  <ol>
  <li><p>pattern is a new line, pattern2 and pattern4 is \n. Why python regex generates the same pattern for different string? </p></li>
  <li><p>Not sure why pattern3 also generates the same pattern. When passed to re parser, pattern3 stands for \ + new line, why re parser translates that into just matching new line?</p></li>
  </ol>
  
  <p>I am using Python 3</p>