Just to chime in.... The RegexKit linked below is absolutely FANTASTIC. I use it pretty much any time I need to do beyond-basic text manipulation. RegexKitLite is some NSString categories, allowing you to do things like [myString isMatchedByRegex:@"some regex"] and so on. It's incredibly useful.

Dave

On Mar 31, 2009, at 5:55 PM, John Engelhart wrote:

You can use regular expressions.  RegexKitLite @
http://regexkit.sourceforge.net/RegexKitLite/ which you can download at
http://downloads.sourceforge.net/regexkit/RegexKitLite-2.2.tar.bz2

For example, you can be extremely lazy and do something along the lines of:

NSStringEncoding fileEncoding;
NSString *fileString = [[NSString stringWithContentsOfFile:@"file.txt"
usedEncoding:&fileEncoding error:NULL] stringByReplacingOccurrencesOfRegex:@
"[\u201c\u201d]" withString:@"\""];

And violla! This will turn “ (\u201c) and ” (\u201d) in 'file.txt' into a
plain " (ascii 0x22), the result of which is fileString.

There's other methods available as well if you just need to find the
locations of the curly quotes and what not.  Well documented, and the
documentation is available in .docset format so it's integrated and
available inside Xcode, just like all the other documentation.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/davedelong%40me.com

This email sent to davedel...@me.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to