title: Javascript regex to find a particular string which could be broken across multiple lines
body: <p>I'm trying to write a regex which gets a particular substring from a string. However, the substring could be broken across multiple lines.</p>
  
  <p>I've tried using the multiline flag, like this:</p>
  
  <p><code>"foo\nbar".match(/foobar/m)</code></p>
  
  <p>But that returns <code>null</code>. </p>
  
  <p>I've also seen a number of posts suggesting I use <code>[\S\s]</code>. However, as far as I can tell, this only works if you know where the break line will be, like this:</p>
  
  <p><code>'foo\nbar'.match(/foo[\S\s]bar/m)</code></p>
  
  <p>Is there a way to find all instaces of <code>foobar</code> in a string when the line break could anywhere in the string? </p>