Whoops, I meant 

Are you numbers constrained to be from 1 to 9? How about 0677 (which is 
actually 6 and 77) or 0607 (which is actually 607) etc?

Phil

On Aug 10, 2013, at 2:54 PM, Tom Davie <tom.da...@gmail.com> wrote:

> 
> On 10 Aug 2013, at 22:44, Keary Suska <cocoa-...@esoteritech.com> wrote:
> 
>> On Aug 10, 2013, at 12:17 PM, Tom Davie wrote:
>> 
>>> Heh, I’d actually argue that NSScanner is a much much better API to use 
>>> here (and in fact nearly everywhere).  Regular expressions constrain you 
>>> only to regular grammars, which are a pretty small set.  In my experience 
>>> 99% of the use of them is actually trying to parse something that’s not 
>>> *quite* a regular grammar, and uses a hack on top of regular expressions to 
>>> do something not-quite-right.
>>> 
>>> NSScanner by comparison makes the separation of what’s 
>>> scanning/tokenisation, and what’s up to your (turing complete) program much 
>>> more clear.  So basically, (at least in my opinion), if you want to parse 
>>> something that’s regular, NSScanner is a great choice.  If you want to 
>>> parse something that’s context free, look at CoreParse (Not tooting my own 
>>> horn, honest).  And finally, if you want to parse something that’s more 
>>> even than that, then you’re probably back to NSScanner and a turing 
>>> complete program.
>>> 
>>> About the only use for regular expressions I can think of is asking 
>>> NSScanner to scan something that it doesn’t by default know about.
>> 
>> I would agree that NSScanner is a better API than NSRegularExpression, but I 
>> think that is Apple's fault because there are better regex API's, such as 
>> RegexKit.
>> 
>> I would argue, however, that it is NSScanner that only functions well with 
>> fixed and unvarying grammars and has no context, other than a specific, 
>> unvarying linear progression. Regular expressions have a huge grammar and 
>> when you consider conditionals and zero-width assertions you can parse 
>> information that would send NSScanner into dizzying fits.
>> 
>> Not to mention that NSScanner can't even touch the problem that the OP is 
>> experiencing, while regular expressions will handle it very nicely.
> 
> No, some hacked on extensions to regular expressions can do this.  Because 
> people keep repeatedly bumping into the problem that they’re not as powerful 
> as CFGs, and most parsing problems aren’t regular.
> 
> Tom Davie
> _______________________________________________
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/ershler%40cvrti.utah.edu
> 
> This email sent to ersh...@cvrti.utah.edu

Philip R. Ershler Ph.D.
University of Utah
Cardiovascular Research and Training Institute
95 South 2000 East
Salt Lake City, UT 84112-5000

phone: (801) 230-8771
alt ph: (801) 587-9528
fax: (801) 581-3128
e-mail: ersh...@cvrti.utah.edu


_______________________________________________

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:
https://lists.apple.com/mailman/options/cocoa-dev/ershler%40cvrti.utah.edu

This email sent to ersh...@cvrti.utah.edu

_______________________________________________

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to