Re: String processing
Re: String processing
- Subject: Re: String processing
- From: James Bucanek <email@hidden>
- Date: Mon, 19 Mar 2007 08:16:27 -0700
Robert Walker wrote on Monday, March 19, 2007:
>I have a need to "camelize" some strings. I have some strings
>representing XML tags in the format "some-tag-name" and I want to
>process this string into "someTagName" and I'll also need to convert
>"someTagName" into "some-tag-name" format.
>
>In my research for a solution it appears to me that NSScanner may be
>used to do this conversion. I was thinking of creating a category on
>NSString and using NSScanner to search for instances of the dash.
>But, I'm not sure if this will work for converting the other
>direction. Is there a convenient way to scan for capital letters
>using NSScanner? Is NSScanner actually useful here or is there a
>better way to do this?
While creating you're own NSScanner might work, it seems a little overkill to me. Regardless of whether you create an NSScanner or make this a catagory of NSString, you're still going to need to search the strings for the hyphens and capital letters. I'd look at NSCharacterSet and the string search methods that use it. NSCharacterSet has predefined sets for upper and lower case Unicode character sets.
--
James Bucanek
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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