Re: NSString Parsing
Re: NSString Parsing
- Subject: Re: NSString Parsing
- From: Peer Allan <email@hidden>
- Date: Tue, 29 Oct 2002 15:27:39 -0600
On 10/29/02 2:50 PM, "John C. Randolph" <email@hidden> wrote:
>
There is of course, Mike Ferris's MOKit, which includes the MORegex
>
class.
>
>
-jcr
First I would like to thank everyone who responded to my post. It has no
only helped me but gave me ideas on how to solve some completely unrelated
issues I have with other application ideas.
As for the MOKit, I have just been playing with it and I am trying to figure
out if there is a "Find All" functionality. Last night I was playing with
OmniFoundation and OFRegularExpression and it had a nice findNextMatch
method to iterate through the string. Can MOKit do something similar?
Right now I am finding the first match, saving it, removing the range from
the base string and then finding the next one in the remaining string. Here
is a synopsis of my code:
NSMutableString *captureString = [[NSString alloc]
initWithContentsOfURL:myURL];
MORegularExpression *regex = [[MORegularExpression alloc]
initWithExpressionString:@"<td>(.*?)</td>" ignoreCase:YES];
NSMutableString *testString = [[NSMutableString alloc] init];
NSRange theRange;
while ([regex matchesString:captureString]) {
theRange = [regex rangeForSubexpressionAtIndex:0
inString:captureString];
[testString appendString:[regex substringForSubexpressionAtIndex:1
inString:captureString]];];
[captureString deleteCharactersInRange:theRange];
}
[resultField setString:testString];
Is there a better way to do this with the MOKit?
Thanks in advance,
Peer
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.