title: Extracting paragraphs containing a particular string from a group of paragraph having all paragraphs with same start and end
body: <p>I need to Extract  paragraphs containing a particular string from a group of  paragraph having all paragraphs with same start and end</p>
  
  <p>for example: In the below text, all the paragraphs' first line starts with "Thread" and last line starts with "Breadcrumb", Now I want to extract only those paragraphs which contains "string_to_be_searched"</p>
  
  <pre><code> Thread 1398 (Thread name)
      data...
      Breadcrumb: some alpha numeric data
  
    Thread 1398 (Thread name)
      data...
      string_to_be_searched
      Breadcrumb: some alpha numeric data
  
  
  
    Thread 1398 (Thread name)
      data...
      Breadcrumb: some alpha numeric data
  
   Thread 1398 (Thread name)
      data...
      string_to_be_searched
      Breadcrumb: some alpha numeric data
  
   Thread 1398 (Thread name)
      data...
      Breadcrumb: some alpha numeric data
  </code></pre>
  
  <p>I have tried it using a regular expression but when I try it without g option it gives me first two threads and when I do it with g it gives me first 4 threads, instead it should give me only 2nd and 3rd thread.</p>
  
  <pre><code>var re = /(Thread[\s\S]*?sys_mlock[\s\S]*?Bread.*)/m; 
  </code></pre>
  
  <p>Problem Demo: <a href="https://regex101.com/r/nR3qG9/2" rel="nofollow">https://regex101.com/r/nR3qG9/2</a></p>