• 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: String processing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: String processing
      • From: Andreas Mayer <email@hidden>
References: 
 >String processing (From: Robert Walker <email@hidden>)

  • Prev by Date: String processing
  • Next by Date: Re: Changing order of views dynamically
  • Previous by thread: String processing
  • Next by thread: Re: String processing
  • Index(es):
    • Date
    • Thread