从文件中删除冗余的单词 [英] eleminating redundant words from a file

查看:82
本文介绍了从文件中删除冗余的单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,

我需要一些帮助吗?


我有一个看起来像这样的文件:


猫猫猫狗狗猫狗猫猫狗狗狗狗

放低放猫狗狗猫猫咪放入


该文件的输出看起来会像这样:


猫狗猫狗猫狗

放低放猫狗猫放





这意味着没有两个相似的单词会重复。


让文件名为:repfile


在shell中我这样做:

< span class =codeLinkonclick =Blur(this,this.parentNode.parentNode,getChildren(this),true);>展开 | 选择 | Wrap | 行号

解决方案

您可以使用正则表达式以简单的方式实现它:

展开 | 选择 | Wrap | 行号


要回答你的确切问题,即如何分隔一行中的单词,你可以使用分割功能。

展开 | 选择 | Wrap | 行号


< blockquote class =post_quotes>
您可以使用正则表达式以一种简单的方式实现它:

展开 | 选择 | Wrap | 行号


Hi Friends,
I need a little help?.

I have a file that looks like this:

cat cat cat dog dog cat dog cat cat dog dog
put put low put put cat dog dog cat cat put


The output of the file will look some thing like this:

cat dog cat dog cat dog
put low put cat dog cat put
.
.
That means no two words similar will repeat.

Let the file name is: repfile

In shell I am doing it like this:

Expand|Select|Wrap|Line Numbers

解决方案

You can achieve it using regular expressions in a simple way:

Expand|Select|Wrap|Line Numbers


To answer your exact question i.e how to separate words in a line, you can use split function.

Expand|Select|Wrap|Line Numbers


You can achieve it using regular expressions in a simple way:

Expand|Select|Wrap|Line Numbers


这篇关于从文件中删除冗余的单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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