Re: NSScanner question

2013-03-20 Thread Graham Cox
On 21/03/2013, at 12:53 AM, Gerd Knops wrote: > Can't agree here, I have used NSScanner to parse quite a few even complex > file formats, and NSScanner was a pretty convenient (and fast!) solution for > these cases. It's useful, but not as useful as it could be. It *looks* as if it could be

Re: NSScanner question

2013-03-20 Thread Gerd Knops
Can't agree here, I have used NSScanner to parse quite a few even complex file formats, and NSScanner was a pretty convenient (and fast!) solution for these cases. Gerd On Mar 19, 2013, at 8:37 PM, Jens Alfke wrote: > > On Mar 19, 2013, at 4:37 PM, Graham Cox wrote: > >> I don't find NSSca

Re: NSScanner question

2013-03-19 Thread Koen van der Drift
I agree with you guys as well about the limits of NSScanner. In this case it is a fairly simple extraction of a few substrings for a short string, and it works just fine with the NSScanner. - Koen. On Mar 19, 2013, at 9:37 PM, Jens Alfke wrote: > > On Mar 19, 2013, at 4:37 PM, Graham Cox w

Re: NSScanner question

2013-03-19 Thread Jens Alfke
On Mar 19, 2013, at 4:37 PM, Graham Cox wrote: > I don't find NSScanner all that useful for searching for specific strings in > a stream. Agreed. There is a very narrow range of use cases for NSScanner — simple searches can be done with NS[Mutable]String directly, and more sophisticated ones

Re: NSScanner question

2013-03-19 Thread Graham Cox
On 20/03/2013, at 1:01 AM, Koen van der Drift 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

Re: NSScanner question

2013-03-19 Thread Koen van der Drift
On Mar 19, 2013, at 10:27 AM, Michael Starke wrote: > Another way might be to use NSString rangeOfString with NSRange.location you > can then identify your first end second occurring Needle? Excellent solution, thanks! And I learned a new word today: "Needle". - Koen.

Re: NSScanner question

2013-03-19 Thread Michael Starke
If you cannot use single characterts as Needles to be able to use the scanUpToCharartersFromSet how about scanning for both strings and compare the prefixes in the results? If you encounter one string in the other you know that you scanned for the second occurence at the first run and you can

Re: NSScanner question

2008-04-23 Thread Jason Wiggins
Thanks Michael for your reply. I guess I should be doing more validity checks. I'll play some more. Thanks for the suggestion. Regards, Jason On 23/04/2008, at 7:57 PM, Michael Vannorsdel wrote: At first glance I'd say it's crashing because you're not checking if scanUpToCharactersFromSet:in

Re: NSScanner question

2008-04-23 Thread Michael Vannorsdel
At first glance I'd say it's crashing because you're not checking if scanUpToCharactersFromSet:intoString: was successful and trying to add what may be an invalid object (foundStrings) to an array. On Apr 23, 2008, at 3:46 AM, Jason Wiggins wrote: I've been playing with NSScanner to cut a s