Re: Parsing NSString
Re: Parsing NSString
- Subject: Re: Parsing NSString
- From: "Michael A. Crawford" <email@hidden>
- Date: Tue, 25 Jan 2005 04:31:14 -0800
We have a winner! Thank you Martin. Henry gets an honorable mention as first-runner-up. Now I need to go back to the documentation and see why I didn't find this when I looked for it.
-Michael
On Jan 25, 2005, at 3:31 AM, Martin Valenta wrote:
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/
----------------------
There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies.
And the other way is to make it so complicated that there are no obvious deficiencies.
-- C.A.R. Hoare
_______________________________________________
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