Re: String Character Replacement
Re: String Character Replacement
- Subject: Re: String Character Replacement
- From: Chas Spillar <email@hidden>
- Date: Fri, 10 Nov 2006 17:36:46 -0800
- Thread-topic: String Character Replacement
Also, for path related substitions...
E.g. /foo/bar/test -> \foo\bar\test
Check out the path utilities NSString category methods. These are extremely
powerful...
Chas.
> From: Chas Spillar <email@hidden>
> Date: Fri, 10 Nov 2006 17:33:37 -0800
> To: Julio Cesar Silva dos Santos <email@hidden>
> Cc: Chas Spillar <email@hidden>, Cocoa Dev List
> <email@hidden>
> Conversation: String Character Replacement
> Subject: Re: String Character Replacement
>
> NSMutableString has:
>
> - (unsigned int)replaceOccurrencesOfString:(NSString *)target
> withString:(NSString *)replacement options:(unsigned)opts
> range:(NSRange)searchRange
>
> It escapes me right now, but I believe there is, also, a NSCharacterSet
> based method that has similar functionality.
>
> Also, for general purpose parsing, check out : NSScanner.
>
> Chas.
>
>> From: Julio Cesar Silva dos Santos <email@hidden>
>> Date: Fri, 10 Nov 2006 23:25:27 -0200
>> To: <email@hidden>
>> Subject: Re: String Character Replacement
>>
>> Maybe using a code like this:
>>
>> NSArray * test = [myMutString componentsSeparatedByString:@":"];
>> NSString * newString = [test componentsJoinedByString:@"\t"];
>>
>>
>> Julio Cesar Silva dos Santos
>> email@hidden
>>
>> 2006/11/10, email@hidden <email@hidden>:
>>>
>>> What would be the most efficient way to replace characters in a string?
>>> Say I
>>> have an NSString/NSMutableString that contains...
>>>
>>> Joe:Smith:MI:123:456:8967:M
>>>
>>> ..and I want to replace all the colons with tabs? I suppose that I could
>>> break each field into a substring and then recombine them, but that seems
>>> like way
>>> too many steps for such a simple task. I need something like...
>>>
>>> [myMutString replaceCharacter:':' with:'\t'];
>>>
>>> Looking through the documentation of NSMutableString and NSString I didn't
>>> find anything similar.
>>>
>>> Thanks in advance
>>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Cocoa-dev mailing list (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden