• 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: Running a regular expression on an NSString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Running a regular expression on an NSString


  • Subject: Re: Running a regular expression on an NSString
  • From: "Jeff Galyan" <email@hidden>
  • Date: Fri, 04 Jan 2002 10:34:23 -0700

Why not use the std C regex functionality on a C string?

The NSString documentation tells you how to get a C string from an NSString.


--Jeff

On 1/4/02 9:36 AM, "Matt Neuburg" <email@hidden> wrote:

> On Fri, 28 Dec 2001 14:00:29 -0800, Steven Frank <email@hidden> said:
>
>> Is there an easy way to run a regular expression on an NSString? I
>> don't think NSScanner is going to cut it in this particular case.
>
> I asked the same question on just about my first day using Cocoa. :-) I
> find the lack of built-in regex support astounding. How hard would it be,
> especially since we know Perl is sitting right there on the same machine?
>
> In the end, in fact, I included a Perl script in my project and called it
> with NSTask. I got some help from various folks here on how to structure
> the necessary incantation, so I pass it along:
>
> // run perl script
> NSTask* wdct = [[NSTask alloc] init];
> NSPipe* pipe = [NSPipe pipe];
> NSString* reply;
> NSFileHandle* handle = [pipe fileHandleForReading];
> [wdct setStandardOutput: pipe];
> [wdct setLaunchPath: [[NSBundle mainBundle]
> pathForResource: @"wdct" ofType:nil]];
> [wdct setArguments: [NSArray arrayWithObject: whatever]];
> [wdct launch];
> reply = [[NSString alloc] initWithData: [handle readDataToEndOfFile]
> encoding: NSASCIIStringEncoding];
>
> HTH - m.


References: 
 >Re: Running a regular expression on an NSString (From: Matt Neuburg <email@hidden>)

  • Prev by Date: NSSound - pause and resume
  • Next by Date: Re: Cocoa Developer in Training: Language Question (ObjC or Java)?
  • Previous by thread: Re: Running a regular expression on an NSString
  • Next by thread: Re: Running a regular expression on an NSString
  • Index(es):
    • Date
    • Thread