删除相同的字符串

编程入门 行业动态 更新时间:2024-10-26 00:29:28
本文介绍了删除相同的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个字符串名称="

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".

更多推荐

删除相同的字符串

本文发布于:2023-11-06 09:55:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1563374.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!