我有一行文本想要删除重复项(可能不必直接位于另一行文本之后)。
例如,我想删除这些行中的“First”:
First Second Third First Fourth First Fifth -> First Second Third Fourth Fifth
First Second Third First First Fourth Fifth -> First Second Third Fourth Fifth
我怎样才能实现这个目标?
如果它们正确地采用升序形式(如果没有重复项),那么也许您可以“逃脱”的正则表达式如下:
(First)?\s+(Second)?\s+(Third)?\s+(Fourth)\s+(Fifth)
这将捕获以下内容:
First Second Third Fourth Fifth
First Second Third
Second Third
First Fifth