String parsing advice...
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