title: How to split a string into substrings of equal length
body: <p>So </p>
  
  <pre><code>split("There are fourty-eight characters in this string", 20)
  </code></pre>
  
  <p>should return</p>
  
  <pre><code>["There are fourty-eig", "ht characters in thi","s string"]
  </code></pre>
  
  <p>If I make currentIndex = string.startIndex and then try to advance() it further than a string.endIndex, I get "fatal error: can not increment endIndex" before I check if my currentIndex &lt; string.endIndex so the code below doesn't work</p>
  
  <pre><code>var string = "12345"
  var currentIndex = string.startIndex
  currentIndex = advance(currentIndex, 6)
  if currentIndex &gt; string.endIndex {currentIndex = string.endIndex}
  </code></pre>