NSRegularExpression only finds a single occurrence of my match
NSRegularExpression only finds a single occurrence of my match
- Subject: NSRegularExpression only finds a single occurrence of my match
- From: Devraj Mukherjee <email@hidden>
- Date: Sun, 17 Oct 2010 17:38:58 +1100
Hi all,
I am trying to use Regular Expressions to match uppercase letters in
strings like "numberOfNames" which I want to replace with
number_of_names. Code sample
NSError *error = NULL;
NSRegularExpression *regex = [NSRegularExpression
regularExpressionWithPattern:@"[a-z]+([A-Z][a-z]+)*"
options:NSRegularExpressionAllowCommentsAndWhitespace
error:&error];
NSMutableString *aStr = [NSMutableString
stringWithString:@"numberOfElementsAtHome"];
NSLog(@"%i", [regex numberOfMatchesInString:aStr
options:NSRegularExpressionCaseInsensitive
range:NSMakeRange(0, [aStr length])]);
In all cases my regular expressions matches one occurrence.
Can anyone see what I might be getting wrong?
May be I am using parameters in the regex string that
NSRegularExpression doesn't support?
Thanks a lot.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden