删除相同的字符串 [英] Removing Same String

查看:104
本文介绍了删除相同的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个字符串名称="

i have a string name="

"ThisThis is tested by noornoor"


如果我要删除第二个单词,例如在ma字符串中,是否有要删除的第二个单词,这可以删除其他这个单词吗?
有什么办法吗?


is there any if i want to remove the second word which comes after like in ma string there are to word like ThisThis can i remove other this???
is there any way?

推荐答案

这不是一件简单的任务.例如,您的应用程序如何分辨"noornoor"中的"oo"实际上不是字符串重复?
:)
It''s not a trivial task. For instance how can your application tell that ''oo'' in ''noornoor'' isn''t actually a string repetition?
:)


您可以将每个单词分成相等长度的部分,然后检查各部分是否相等.当然,这不会解决"ThisThisThis"之类的问题...

或者,您可以选择每个单词,然后从第一个字母开始,检查当前字母的另一个实例.您只需检查前n/2个字母即可确定是否有问题.

就像CPallini所说的,这不是一件简单的任务...
You could take each word, divide it into equal-length parts, and check the parts for equality. Of course, this won''t fix things like "ThisThisThis"...

Or you could take each word, and starting with the first letter, check for another instance of the current letter. You only have to check the first n/2 letters to determin if there''s a problem.

Like CPallini stated, it''s not a trivial task...


嗨TanzeelAhmed,

您可以通过将单词分为两个单独的单词并进行验证来轻松实现此目的.但是,如果单个单词由两个这样的字母组合组成(例如:可可,渡渡鸟[鸟名],塔塔,爸爸等),您会怎么做?在这种情况下,这肯定会失败.

您的AI逻辑必须非常复杂才能解决此类情况.电话是您的.如果此回答您的查询,请标记为答案".
Hi TanzeelAhmed,

You can easily do this by dividing the word in two separate words and validate. But, what will you do in such case where a single word consists of two such combination of letters (like: coco, dodo [bird name], tata, papa etc)? In such scenarios this will definitely fail.

Your AI logic must be very complex for solving such scenarios. The call is your. If this answered your query, please "Mark As Answer".


这篇关于删除相同的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆