• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Parsing NSString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Parsing NSString (From: "Michael A. Crawford" <email@hidden>)
 >Re: Parsing NSString (From: Martin Valenta <email@hidden>)

  • Prev by Date: Re: mathematical area of closed vector path
  • Next by Date: Re: Networking
  • Previous by thread: Re: Parsing NSString
  • Next by thread: Re: Parsing NSString
  • Index(es):
    • Date
    • Thread