Hello -

        Whoops!  I can read.

You use the replaceOccurrencesOfString:withString:options:range: method in NSMutableString. It works on the same instance of the string instead of creating a new string.

        For example:

NSMutableString *someString = [NSMutableString stringWithString:@"The quick brown fox"]; [someString replaceOccurrencesOfString:@"quick" withString:@"slow" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [someString length])];

-Bob Warwick
[EMAIL PROTECTED]

On 6-Jun-08, at 4:54 AM, Cemil Browne wrote:

Bob,

Thanks for the reply...

However, stringByReplacingOccurrencesOfString only works in Tiger, though, right? What did everyone do last year for it?

-Cemil
On 06/06/2008, at 5:51 PM, Bob Warwick wrote:

Hello -

There is no regular expression support in Cocoa. You might find http://www.cocoadev.com/index.pl?RegularExpressions useful in helping to find a library to do it for you.

        Search and replace in Cocoa looks like this:

        NSString *someString = @"The quick brown fox";
NSString *newString = [someString stringByReplacingOccurrencesOfString:@"quick" withString:@"slow"];

You can find this in the NSString documentation. It creates a new string with the substring replaced.

-Bob Warwick
[EMAIL PROTECTED]

On 6-Jun-08, at 4:31 AM, Cemil Browne wrote:

Hi all,

This might be a really silly question - but am I missing something obvious? Is there any support at all for regular expressions in the Cocoa libraries?

I can't find anything and I've found some third-party frameworks - but
surely something so necessary must be buried in the string classes
somewhere? How would I do a simple substring search or replace in 10.4?

Thanks,
Cemil
_______________________________________________

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/warwick%40codehackers.net

This email sent to [EMAIL PROTECTED]



_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to