title: Regex to find all substrings and longest substring
body: <p>I would usually do something like this using a string libray. But  I wonder if it can be done using a regex.</p>
  
  <p>I want to do the following: Given a <strong>search string</strong>: </p>
  
  <blockquote>
    <p>Seattle is awesome</p>
  </blockquote>
  
  <p>I want to find all substrings of it in a given sentence. So applying a regex to the following <strong>sentence</strong></p>
  
  <blockquote>
    <p>Seattle Seattle is awesome is awesome awesome is Seattle</p>
  </blockquote>
  
  <p>Should give me</p>
  
  <blockquote>
    <p>Seattle, Seattle is awesome, is awesome, awesome, is, Seattle</p>
  </blockquote>
  
  <p><strong>One constraint that might be helpful is that the sentence will always have only the words present in the search string and whitespaces in between.</strong></p>
  
  <p><strong>Note</strong> If there's a match, it should be the longest possible string. So like in the above example the matches shouldn't be single words rather longest possible substrings. Order among words also needs to be maintained. That's why </p>
  
  <blockquote>
    <p>awesome is Seattle </p>
  </blockquote>
  
  <p>in the sentence above gives us</p>
  
  <blockquote>
    <p>awesome, is and Seattle</p>
  </blockquote>
  
  <p>I am not sure if something like this can be done with a regex though, since it is greedy. Would appreciate any insight into this!
  I'm familiar with both C# and Java and could use either of their regex libraries.</p>