我刪除重複的文字:從多個字符串
a = "This is Product A with property B and propery C. Buy it now!"
b = "This is Product B with property X and propery Y. Buy it now!"
c = "This is Product C having no properties. Buy it now!"
我正在尋找一種算法,可以這樣做:
> magic(a, b, c)
=> ['A with property B and propery C',
'B with property X and propery Y',
'C having no properties']
我必須找到在1000+文本重複。超級表演不是必須的,但會很好。
- 更新
我正在尋找單詞序列。所以,如果:
d = 'This is Product D with text engraving: "Buy". Buy it now!'
第一個「賣」不應該重複。我猜測我必須使用n之後的字眼,以便看作是重複的。
問題不明確?如何定義重複的文本? –
爲什麼「有財產」在重複時不重複? :D – fl00r
1)如果有第四個字符串「Bumblebee zebra」。 '魔術(a,b,c,d)'會被期望返回所有四個未修改的字符串? 2)預期如何使用位置信息,例如「魔術師」示例刪除了「立即購買!」儘管事實上這是字符串的不同部分。可能你正在尋找一個'diff'函數? –