• 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
String parsing advice...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

String parsing advice...


  • Subject: String parsing advice...
  • From: Martin Linklater <email@hidden>
  • Date: Wed, 12 Dec 2007 03:27:20 -0800

HI. I have a string I need to parse which is a comma separated list of variously typed elements... eg.

"1,0.25,'Hello, this is a string','each\nstring\non\na\mnewline',45,'He said ''hello'' to me',0"

What I want is to split the string up into an NSArray of NSString objects, which I can then enumerate through and process one by one.

I've tried using the NSString method 'componentsSeparatedByString' and using a comma as the separator, but that splits string elements if they have a comma in them...eg:

1
0.25
'Hello
this is a string'
etc...


 I have also tried adding brackets around the source string and separating the elements using the 'propertyList' method, but this seems to get confused by the newline codes ('\n") embedded in string elements.

Before I start coding up my own parsing method which can deal with these problems is there anything in the Cocoa API which would parse my strings robustly - ie deal with string elements which have embedded newline and comma characters in them ?

Thanks.
_______________________________________________

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

  • Follow-Ups:
    • Re: String parsing advice...
      • From: "I. Savant" <email@hidden>
  • Prev by Date: Re: Problem when inheriting settings in xcconfig files
  • Next by Date: Re: String parsing advice...
  • Previous by thread: Re: Newbie: How to know whether an object is in autorelease pool
  • Next by thread: Re: String parsing advice...
  • Index(es):
    • Date
    • Thread