문제

I have two NSString, for example: stringOne = @"1760254913042013"; stringTwo = @"4917602549030391";

I need to compare both strings to find out if both have some string in common. In the example this common string would be @"17602549". Trying to avoid writing some specific code, I been searching in NSScanner, CFString, NSString methods but nothing seems to solve this problem. Some help would be greatly appreciated.

도움이 되었습니까?

해결책

Your two strings have many strings in common, such as "30", "91", and every substring of "17602549". It appears you're looking for the longest substring that two strings have in common.

Google "Objective-C longest common substring", and you'll find this method on Wikibooks.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top