title: Python regex over multiple newlines
body: <p>I have a string which contains multiple file paths, some of which contain arbitrary newlines within the path, and I want to parse the string using python so that only the filenames and extensions remain.</p>
  
  <p>For example:</p>
  
  <pre><code>a/b/c/d/file1.c  
  a/b/c/d/e/f/g/h/1/2/3/4/5/foo.c  
  dir1/dir2/newlinedir  
  /nextlinedir/bar.c
  </code></pre>
  
  <p>should be parsed to give output:</p>
  
  <blockquote>
    <p>file1.c<br>
    foo.c<br>
    bar.c</p>
  </blockquote>
  
  <p>I am using the following regular expression (the groups for the filename and extension must be separate for later purposes):</p>
  
  <pre><code>path_regex = re.compile(r'.*\/([^\/\.]*)(\.c){0,1}$', re.MULTILINE)
  path_regex.sub(r'\g&lt;1&gt;\g&lt;2&gt;', input_string)
  </code></pre>
  
  <p>This will work on strings with single line paths but not paths that contain newlines.
  What should I do?</p>