• 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: Grep Support in Cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Grep Support in Cocoa


  • Subject: Re: Grep Support in Cocoa
  • From: Sherm Pendley <email@hidden>
  • Date: Mon, 10 Mar 2003 22:17:02 -0500

On Monday, March 10, 2003, at 06:02 PM, Tae-Won Ha wrote:

First of all, I have to say that I'm a very newbie to regex.
I downloaded the MOKit and looked at the API-Ref. I've got a question:
What is meant by that index in
- (NSRange)rangeForSubexpressionAtIndex:(unsigned)index inString:(NSString)

A subexpression is part of the regex enclosed in parentheses. For example, you might have a pattern for parsing a simple tab-separated text file with two columns. The first column is a numeric identifier with at least one digit, and the second column may contain any number of characters - including none. The columns are separated by a tab character. The pattern for each line would be:

(\d+)\t(.*)\n

The first subex, at index 1, would contain only the decimal numbers. The tab character, as it's not enclosed in parentheses, is not part of any subex. The subex at index 2 would contain the second column - because * matches zero or more characters, it could be empty.

Fair warning, though: I use regexes quite often in Perl, but I haven't used MOKit. It's possible that when the MOKit authors use the term "subexpression," they mean something other than what I'm used to.

sherm--

If you listen to a UNIX shell, can you hear the C?
_______________________________________________
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.

  • Prev by Date: Re: Grep Support in Cocoa
  • Next by Date: Cocoa/Java: IB parsing classes
  • Previous by thread: Re: Grep Support in Cocoa
  • Next by thread: Re: Grep Support in Cocoa
  • Index(es):
    • Date
    • Thread