Nondeterministic behavior when matching empty strings
Status: Beta
Brought to you by:
jengelhart
When a regex matches an empty string, it returns "NO" every other call, even if the regex matches.
For example, "foo" in the following example will always be "NO", since "[emptyString isMatchedByRegex:regex]" will alternate return values on every call.
NSString* emptyString = @""; NSString* regex = @"^$"; BOOL foo = [emptyString isMatchedByRegex:regex] == [emptyString isMatchedByRegex:regex];
This only works when the regexes are identical, however. For instance:
BOOL bar = [emptyString isMatchedByRegex:@"^$"] == [emptyString isMatchedByRegex:@"^.*$"];
will normally be true, as both statements are likely to be in sync.
Since this technique is used in the "Parsing CSV Data" example, either the documentation or RegexKitLite is in need of an update.
OSX 10.9.2, XCode 5.0.2, 10.9 SDK, ARC off.