title: Split string with regular expression - objective-C
body: <p>I'm quite new to regular expression and I'm trying to learn it.</p>
  
  <p>Here's my string:</p>
  
  <pre><code>Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)
  </code></pre>
  
  <p>And I want to split it up to an array which looks like this:</p>
  
  <pre><code>@[@"Mozzila", @"4.0", @"compatible", @"MSIE 5.0", @"Windows NT", @"DigExt"];
  </code></pre>
  
  <p>This is the code I tried:</p>
  
  <pre><code>NSString *expression = @"Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)";
  NSRegularExpression *testExpression = [NSRegularExpression regularExpressionWithPattern: @"([a-zA-Z]+)/([1-9.]+) \(([a-z]+); ([a-zA-Z .]+); ([a-zA-Z ]+); ([a-zA-Z]+)\)" options:NSRegularExpressionCaseInsensitive error:nil];
                                                                                  options:NSRegularExpressionCaseInsensitive error:nil];
  NSArray *matches = [testExpression matchesInString:expression 
                                             options:0 
                                               range:NSMakeRange(0, [expression length])];
  NSLog(@"%@",matches);
  </code></pre>
  
  <p>Also tried with:</p>
  
  <pre><code>[testExpression enumerateMatchesInString:expression
                                   options:0
                                     range:NSMakeRange(0, [expression length])
                                usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) {
                                    NSLog(@"Value: %@", [expression substringWithRange:[result rangeAtIndex:1]]);
                                }];
  </code></pre>
  
  <p>And also:</p>
  
  <pre><code>NSRegularExpression *testExpression = [NSRegularExpression
                                         regularExpressionWithPattern: @"(\w+)/(\w+) \((\w+);([\w .]+); ([\w ]+); (\w+)\)" options:NSRegularExpressionCaseInsensitive
                                         error:nil];
  </code></pre>
  
  <p>But the log is empty. What am I doing wrong?</p>