Re: Parsing NSString
Re: Parsing NSString
- Subject: Re: Parsing NSString
- From: Martin Valenta <email@hidden>
- Date: Tue, 25 Jan 2005 12:31:57 +0100
You can use OgreKit (http://www-gauge.scphys.kyoto-u.ac.jp/~sonobe/OgreKit/). OgreKit is a regular expressions framework that has a method called:
- (NSArray*)componentsSeparatedByRegularExpressionString:(NSString*)expressionString;
Having a string like this:
NSString* argList = @"command arg1 arg2 \t arg3 \t\targ4";
you can parse it for example that way:
[argList componentsSeparatedByRegularExpressionString: @"[ \t]*"
this yields the array:
@"command", @"arg1", @"arg2", @"arg3", @"arg4"
There's no (easy) way to do a componentsSeperatedByAnyOfTheseStrings:, unfortunately.
Fortunately there is an easy way ;-)
Some information about regular expressions and a tutorial as a starting point can be found here: http://regular-expressions.info/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden