On 20/03/2013, at 1:01 AM, Koen van der Drift <koenvanderdr...@gmail.com> wrote:

> I have the following string:   "this is a test AA string to capture BB and 
> some more". I am using an NSScanner to extract the string to capture.  I scan 
> up to AA, and then up to BB. However, sometimes, the string can be: "this is 
> a test BB string to capture AA and some more". When I now use the scanner to 
> scan for AA first, I will already be past my target string. Unfortunately, I 
> do not know in advance if AA comes before BB or the other way around.
> 
> Any suggestions how to solve this with an NSScanner?


I don't find NSScanner all that useful for searching for specific strings in a 
stream. For example, they don't make a good tokenizer for structured grammars, 
except in the limited case of a token being a single character. It would be 
useful if it were extended to allow use of lists of words that had some 
specific meaning using a dictionary (in an analogous manner to the way it can 
use character sets), but that's an exercise for another day.

Can you not just search for the substrings using the -rangeOfString: family of 
methods in NSString?


--Graham


_______________________________________________

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