• 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: Fastest/smallest search+replace
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fastest/smallest search+replace


  • Subject: Re: Fastest/smallest search+replace
  • From: Greg Titus <email@hidden>
  • Date: Mon, 14 May 2001 19:22:02 -0700

Hey John,

Thought I'd mention OFRegularExpression to the list here, even though I
know you know about it. (I think you've even posted pointers to it
before on the macosx-dev list...) Do you have issues with our
implementation, or just think this would be something that should be
built into Cocoa by Apple?

The OmniFoundation framework at
http://www.omnigroup.com/community/developer/sourcecode includes a
couple of regular expression classes OFRegularExpression and
OFRegularExpressionMatch. They handle full Unicode regex's and strings.

On Monday, May 14, 2001, at 03:16 PM, John C. Randolph wrote:
> Yes, and while you're at it, how about a good selection of the rest of
> the string-bashing functionality that Perl or Python offer? In
> particular, the tr/// operator would be *very* nice to have, and a
> "NSRegex" class that kept the compiled expressions around would be a
> nice addition to the NSScanner functionality.

The OF equivalent code for these is:

> nameExpression = [[NSRegex alloc] initWithPattern:@"[A-Za-z]*"];

nameExpression = [[OFRegularExpression alloc]
initWithString:@"[A-Za-z]*"];

> [myScanner scanPattern:nameExpression intoString:&nameString];

match = [nameExpression matchInScanner:myScanner];
nameString = [match matchString];

> [myMutableString searchForPattern:nameExpression
> andReplaceWithString:@"Some Other Name"];

match = [nameExpression matchInString:myMutableString];
[myMutableString replaceCharactersInRange:[match matchRange]
withString:@"Some Other Name"];

Cheers!
--Greg


  • Follow-Ups:
    • Re: Fastest/smallest search+replace
      • From: "John C. Randolph" <email@hidden>
References: 
 >Re: Fastest/smallest search+replace (From: "John C. Randolph" <email@hidden>)

  • Prev by Date: Re: Volume Tracking in Cocoa without Carbon?
  • Next by Date: mathematical functions?
  • Previous by thread: Re: Fastest/smallest search+replace
  • Next by thread: Re: Fastest/smallest search+replace
  • Index(es):
    • Date
    • Thread