I have NSStringwith a few sentences, and I would like to break it down into NSArraysentences. Has anyone solved this problem before? I found enumerateSubstringsInRange:options:usingBlock:one that can do this, but it looks like it is not available on iPhone (Snow Leopard only). I was thinking about period-based line splitting, but that doesn't seem very reliable.
NSString
NSArray
enumerateSubstringsInRange:options:usingBlock:
So far, my best option seems to have been to use RegexKitLite to regularly express it in an array of sentences. Solutions?
CFStringTokenizer. kCFStringTokenizerUnitSentence.
kCFStringTokenizerUnitSentence
,
NSScanner *sherLock = [NSCanner scannerWithString:yourString]; // autoreleased NSMutableArray *theArray = [NSMutableArray array]; // autoreleased while( ![sherLock isAtEnd] ){ NSString *sentence = @""; // . + a space, your sentences probably will have that, and you // could try scanning for a newline \n but iam not sure your sentences // are seperated by it [sherLock scanUpToString:@". " inToString:&sentence]; [theArray addObject:sentence]; }
, , . NSScanner , .. , .
, , NSString, NSCharacterSet NSScanner. , -[NSScanner scanUpToCharactersFromSet:intoString:]. , , .
-[NSScanner scanUpToCharactersFromSet:intoString:]
, .
:
NSArray *sentences = [string componentsSeparatedByString:@". "];
( "", "", "" ) ", , ".
NSArray * sentences = [asthmatic componentsSeparatedByCharactersInSet: [NSCharacterSet punctuationCharacterSet]];
Source: https://habr.com/ru/post/1730316/More articles:Android SDK Demo Trial - androidОпределение того, что слово "есть" - категоризация токена - searchHow can you speed up the restart of an ASP.NET application? - performanceCan I get my copy of Mechanize.Browser to stay on the same page after calling b.form.submit ()? - pythonHow to quickly launch an ASP.Net application to reboot / recycle on a site with high traffic? - performanceWhy does my yui datatable inside the updated panel disappear after postback? - asp.netAbsoluteToNanoseconds vs AbsoluteToDuration - objective-cI want to get the status of running applications - androidSeparate full sentences in a block of text NSString - iosCan 16bit.com executables call win32 API? - apiAll Articles