title: Split string on multiple delimiters of any length in Haskell
body: <p>I am attempting a Haskell coding challenge where, given a certain string with a prefix indicating which substrings are delimiting markers, a list needs to be built from the input. </p>
  
  <p>I have already solved the problem for multiple single-length delimiters, but I am stuck with the problem where the delimiters can be any length.  I use splitOneOf from Data.List.Split, but this works for character (length 1) delimiters only.</p>
  
  <p>For example, given</p>
  
  <p><strong>input</strong> <code>";,\n1;2,3,4;10"</code>, </p>
  
  <p><strong>delimiters</strong> are <code>';'</code> and <code>','</code></p>
  
  <p><strong>splitting</strong> the input on the above delivers</p>
  
  <p><strong>output</strong> <code>[1,2,3,4,10]</code>  </p>
  
  <p>The problem I'm facing has two parts: </p>
  
  <p>Firstly, a single delimiter of any length, e.g. </p>
  
  <p><code>"****\n1****2****3****4****10"</code> should result in the list <code>[1,2,3,4,10]</code>. </p>
  
  <p>Secondly, more than one delimiter can be specified, e.g. </p>
  
  <p><strong>input</strong> <code>"[***][||]\n1***2||3||4***10"</code>, </p>
  
  <p><strong>delimiters</strong> are <code>"***"</code> and <code>"||"</code></p>
  
  <p><strong>splitting</strong> the input on the above delivers</p>
  
  <p><strong>output</strong> <code>[1,2,3,4,10]</code>  </p>
  
  <p>My code for retrieving the delimiter in the case of character delimiters: </p>
  
  <pre><code>--This gives the delimiters as a list of characters, i.e. a String.
  getDelimiter::String-&gt;[Char]
  getDelimiter text = head . splitOn "\n" $ text
  
  --drop "[delimiters]\n" from the input
  body::String-&gt;String
  body text = drop ((length . getDelimiter $ text)+1)) $ text 
  
  --returns tuple with fst being the delimiters, snd the body of the input
  doc::String-&gt;(String,String) 
  doc text = (getDelimiter text, body text)
  
  --given the delimiters and the body of the input, return a list of strings
  numbers::(String,String)-&gt;[String]
  numbers (delim, rest) = splitOneOf delim rest
  
  --input ",@#\n1,2@3#4" gives output ["1","2","3","4"]
  getList::String-&gt;[String]
  getList text = numbers . doc $ text
  </code></pre>
  
  <p>So my question is, how do I do the processing for when the delimiters are e.g. <code>"***"</code> and <code>"||"</code>?</p>
  
  <p>Any hints are welcome, especially in a functional programming context.</p>