如何获取 nsstring 与其他 nsstring 对象的匹配计数?
我很长时间都在寻找一种获取 nsstring 对象的匹配计数的方法。 但我找不到。 如何获取 String_one 和 String_Two 的匹配计数? 我需要你的帮助..
NSString *String_one = @"A!B!C!D!E!F!G";
NSString *String_Two = @"BEF";
// matching progress
// :
// :
// and then result display
NSLog(@"matching count : %d",[??????]);
// result what i want.
// matching count : 3 (A!B!C!D!E!F!G vs BEF => 3 character matches)
I searching a way to get match count of nsstring objects for a long time.
but I can't find.
How to get match count of String_one and String_Two?
I need your help..
NSString *String_one = @"A!B!C!D!E!F!G";
NSString *String_Two = @"BEF";
// matching progress
// :
// :
// and then result display
NSLog(@"matching count : %d",[??????]);
// result what i want.
// matching count : 3 (A!B!C!D!E!F!G vs BEF => 3 character matches)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果你想在这里找到最长的公共子序列,你有链接:
http://en.wikipedia.org/wiki/ Longest_common_subsequence_problem
但是,如果您只想计算第一个字符串中有多少个字符出现在第二个字符串中,您可以自己编写算法。例子:
If you want to find longest common subsequence here you have link:
http://en.wikipedia.org/wiki/Longest_common_subsequence_problem
But if you want count only how many how many character from first string appear in second string you can write algorithm by yourself. Example: