title: How to create String split extension with regex in Swift?
body: <p>I wrote extension that create <code>split</code> method:</p>
  
  <pre><code>extension String {
      func split(splitter: String) -&gt; Array&lt;String&gt; {
          return self.componentsSeparatedByString(splitter)
      }
  }
  </code></pre>
  
  <p>So in playground I can write:</p>
  
  <pre><code>var str = "Hello, playground"
  
  if str.split(",").count &gt; 1{
      var out = str.split(",")[0]
  
      println("output: \(out)") // output: Hello
  }
  </code></pre>
  
  <p>What do I need to make it work with regex like in Java:</p>
  
  <pre><code>str.split("[ ]+")
  </code></pre>
  
  <p>Because this way it doesn't work.</p>
  
  <p>Thanks,</p>