<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to 58: captureComponents on empty string inconsistent</title><link>https://sourceforge.net/p/regexkit/bugs/58/</link><description>Recent changes to 58: captureComponents on empty string inconsistent</description><atom:link href="https://sourceforge.net/p/regexkit/bugs/58/feed.rss" rel="self"/><language>en</language><lastBuildDate>Thu, 30 Dec 2010 02:16:44 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/regexkit/bugs/58/feed.rss" rel="self" type="application/rss+xml"/><item><title>captureComponents on empty string inconsistent</title><link>https://sourceforge.net/p/regexkit/bugs/58/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;If an empty string invokes captureComponentsMatchedByRegex, the results should be an array of empty strings (one for each component, plus one for the entire match).  However, the following code reports that out of 1000 iterations, the capture array is empty 500 times, and has two elements the other 500 times.&lt;/p&gt;
&lt;p&gt;int iterations = 1000;&lt;br /&gt;
int empties = 0, twos = 0;&lt;br /&gt;
for (int i = 0; i &amp;lt; iterations; i++) {&lt;br /&gt;
NSString *exp = @"";&lt;br /&gt;
NSString *regex = @"( *)";&lt;br /&gt;
NSArray *matches = [exp captureComponentsMatchedByRegex:regex];&lt;br /&gt;
if ([matches count] == 0) {&lt;br /&gt;
empties++;&lt;br /&gt;
} else if ([matches count] == 2) {&lt;br /&gt;
twos++;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
NSLog(@"%d empties, %d twos out of %d iterations", empties, twos, iterations);&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Brian Schack</dc:creator><pubDate>Thu, 30 Dec 2010 02:16:44 -0000</pubDate><guid>https://sourceforge.nete3130bb9f49328a9128251ed75f1fc445d1644f1</guid></item></channel></rss>