Search and replace string

kainjow

Registered
Does anybody know how to replace certain strings withint another string? Like...

NSString *alphabet = @"abcdefghijklmnopqrstuvwxyz";

I want to replace "abc" in the alphabet with "cba". Does anybody know how to do that? Just with normal strings, not with attributed strings.

Thanks!!
 
So you guys don't know how to do a basic function in Cocoa?

I thought you guys were smart here! Prove it to me!
 
Originally posted by kainjow
I thought you guys were smart here! Prove it to me!
Hmm... I suddenly got a flicker on my Troll-O-Meter...

A quick search on Google turned up this link at the MacDevcenter.

I don't know Cocoa, but I do know how to use the web...
 
Yes I did use Google and I know how to use the web and I've read that site you referred me to and no it doesn't answer my question. Thanks anyways...Anyone else?
 
hi boys and girls:


s/abc/bca/g



of course that won't work in objc... maybe with the omniframeworks installed...

i suggest the NSRange way described above, it's probably the easiest way. had it been perl though... s/abc/cba/ !


theo
 
Um, yeah. If this was Perl, I'd also have about twenty pages to send for development information.
 
Thanks a lot!! That works for me and helps so much. Where did you find that? It seems like I looked all over the documentation and couldn't find it!

Thanks!
 
Assuming you're referring to the info from zots, it's in the documentation I linked to in my first post. Or in the documetation linked from that post (to the Apple developer docs).

If you're talking about the s/abc/cba/ bit, that's general Perl, so I don't know where iconara found it... ;)
 
Back
Top