title: How to find matches around fixed strings
body: <p>I'm looking for help finding Python functions that allow me to take a list of strings, such as <code>["I like ", " and ", " because "]</code> and a single target string, such as <code>"I like lettuce and carrots and onions because I do"</code>, and finds all the ways the characters in the target string can be grouped such that each of the strings in the list comes in order.</p>
  
  <p>For example:</p>
  
  <pre><code>solution(["I like ", " and ", " because ", "do"],
           "I like lettuce and carrots and onions because I do")
  </code></pre>
  
  <p>should return:</p>
  
  <pre><code>[("I like ", "lettuce", " and ", "carrots and onions", " because ", "I ", "do"), 
   ("I like ", "lettuce and carrots", " and ", "onions", " because ", "I ", "do")]
  </code></pre>
  
  <p>Notice that in each of the tuples, the strings in the list parameter are there in order, and the function returns each of the possible ways to split up the target string in order to achieve this.</p>
  
  <p>Another example, this time with only one possible way of organizing the characters:</p>
  
  <pre><code>solution(["take ", " to the park"], "take Alice to the park")
  </code></pre>
  
  <p>should give the result:</p>
  
  <pre><code>[("take ", "Alice", " to the park")]
  </code></pre>
  
  <p>Here's an example where there is no way to organize the characters correctly:</p>
  
  <pre><code>solution(["I like ", " because ", ""],
           "I don't like cheese because I'm lactose-intolerant")
  </code></pre>
  
  <p>should give back:</p>
  
  <pre><code>[]
  </code></pre>
  
  <p>because there is no way to do it. Notice that the <code>"I like "</code> in the first parameter cannot be split up. The target string doesn't have the string <code>"I like "</code> in it, so there's no way it could match.</p>
  
  <p>Here's a final example, again with multiple options:</p>
  
  <pre><code>solution(["I", "want", "or", "done"],
           "I want my sandwich or I want my pizza or salad done")
  </code></pre>
  
  <p>should return</p>
  
  <pre><code>[("I", " ", "want", " my sandwich ", "or", " I want my pizza or salad ", "done"),
   ("I", " ", "want", " my sandwich or I want my pizza ", "or", " salad ", "done"),
   ("I", " want my sandwich or I", "want", " my pizza ", "or", " salad ", "done")]`
  </code></pre>
  
  <p>Notice that, again, each of the strings <code>["I", "want", "or", "done"]</code> is included in each of the tuples, in order, and that the rest of the characters are reordered around those strings in any way possible. The list of all the possible reorderings is what is returned.</p>
  
  <p>Note that it's also assumed that the first string in the list will appear at the start of the target string, and the last string in the list will appear at the end of the target string. (If they don't, the function should return an empty list.)</p>
  
  <p><strong>What Python functions will allow me to do this?</strong></p>
  
  <p>I've tried using regex functions, but it seems to fail in the cases where there's more than one option.</p>