• 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: NSString Parsing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSString Parsing


  • Subject: Re: NSString Parsing
  • From: "John C. Randolph" <email@hidden>
  • Date: Tue, 29 Oct 2002 12:50:42 -0800

There is of course, Mike Ferris's MOKit, which includes the MORegex class.

-jcr

On Tuesday, October 29, 2002, at 09:48 AM, mike wrote:

On Tue, 29 Oct 2002, Chris Parker wrote:

On Tuesday, October 29, 2002, at 12:32 AM, Simon Stapleton wrote:

From: Peer Allan <email@hidden>

What I want to do is extract all the text from in between a pair or
tags
(<td>...</td> for example). I know I could use a rangeOfString: call
to get
the first one, but then I have to create a new string with the
remaining
data and call rangeOfString: again to get the next and on and on
until the
whole string is parsed. I hope there is a better way to do this.


This is a problem I've had to deal with a couple of times (NOT in the
realm of Cocoa) and the best solution I could come up with was to use
regular expressions. I'm not sure if any C/Obj-C regex packages exist but
you could interface with a perl script. Perl's set of regular expressions
are second-to-none. Extracting the data from between <td> tags can be
done in literally one line:

...
print $1 if m!<TD.*?>(.*?)</TD>!i;
...

Of course, the next problem is how to call the perl routine. The easiest
way would be to write a stand-alone script and use an intermediate file or
do a fork/exec/pipe. If you don't want the overhead of spawning a new
process, perl is embeddable into C (and presumably Obj-C, since it is a
true superset of C) but that could get really hairy really quickly.

Sorry if this if off-topic.

-mike

----
michael a. ericson www.unm.edu/~maerics
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


John C. Randolph <email@hidden> (408) 974-8819
Sr. Cocoa Software Engineer,
Apple Worldwide Developer Relations
http://developer.apple.com/cocoa/index.html
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: NSString Parsing
      • From: Scott Anguish <email@hidden>
    • Re: NSString Parsing
      • From: Peer Allan <email@hidden>
References: 
 >Re: NSString Parsing (From: mike <email@hidden>)

  • Prev by Date: Re: erase then draw image?
  • Next by Date: Re: NSString Parsing
  • Previous by thread: Re: NSString Parsing
  • Next by thread: Re: NSString Parsing
  • Index(es):
    • Date
    • Thread