title: Problems while parsing date with NSRegularExpression
body: <p>I'm trying to parse string with date format like MM/YY and store month and year variables.</p>
  
  <p>I wrote this code and can't figure out why when I pass string like "1":</p>
  
  <ul>
  <li><code>match.numberOfRanges</code> == 3 </li>
  <li><code>match.rangeAtindex(2)</code> == (9223372036854775807,0)</li>
  </ul>
  
  <p>Here is my code (regex has only two groups, so I don't understand how number of ranges can be even theoretically more than 2).</p>
  
  <pre><code>let regex = NSRegularExpression(pattern: "^(\\d{1,2})?[\\s/]*(\\d{1,2})?", options: NSRegularExpressionOptions.allZeros, error: nil)
  // Expiry date string is "1"
  let match = regex?.firstMatchInString(expiryDate, options: NSMatchingOptions.allZeros, range: NSMakeRange(0, expiryDateNS.length))
  
  if let match = match {
      let monthRange = match.rangeAtIndex(1)
      // next string works correct - month contains "1"
      var month = expiryDateNS.substringWithRange(monthRange)
  
      if match.numberOfRanges &gt; 1 {  // match.numberOfRanges returns 3
          let yearRange = match.rangeAtIndex(2) // returns LONG_MAX as location, 0 as length
          // next line will crash
          expiryYear = expiryDateNS.substringWithRange(yearRange)
      }
  }
  </code></pre>
  
  <p><strong>UPDATE</strong>
  As @matt asked, I'm adding few examples here.</p>
  
  <ul>
  <li>String "1" should be parsed and stored as <code>month == "1"</code> and <code>expiryYear == ""</code></li>
  <li>String "12" should be parsed and stored as <code>month == "12"</code> and <code>expiryYear == ""</code></li>
  <li>String "12/45" should be parsed and stored as <code>month == "12"</code> and <code>expiryYear == "45"</code></li>
  </ul>
  
  <p>When I'm parsing string "1" with code above <code>match.numberOfRanges</code> is 3 and <code>match.rangeAtindex(2)</code> is (9223372036854775807,0)</p>