I'm using RKL in a Cocoa app to parse log statements from a wrapped task.
Pattern:
(?:.+) \[.+?\] (.+) \[.+?\] logged in (?:.+)
Test data:
2011-07-11 00:48:19 [INFO] Preparing spawn area: 97
2011-07-11 00:48:19 [INFO] Done (2175837000ns)! For help, type "help" or "?"
2011-07-11 00:48:42 [INFO] mikeyward [/127.0.0.1:59561] logged in with entity id blahblah
Every RegEx tester I've tried on the internet successfully matches the third line and captures 'mikeyward'.
Objective-C code:
NSString *loggedInPattern = @"(?:.+) \\[.+?\\] (.+) \\[.+?\\] logged in (?:.+)";
NSArray *captures = [searchString arrayOfCaptureComponentsMatchedByRegex:loggedInPattern];
NSString *username = [captures objectAtIndex:0];
Problem: Despite having checked to ensure that searchString is valid and contains the sample data, RKL fails to match the line, let alone capture the username. In the example above, an exception is thrown because the captures array is returned with zero objects and I'm not error-checking :)
Any assistance in understanding why regex checkers confirm the match and capture but RKL misses it would be very much appreciated.
Thanks~