vim 字符串出现次数统计(词频)
2015-01-16 16:47
1966 查看
命令
:%s/pattern//gn
参数说明% - 操作区间,全文本;可以使用1, $或行区间替代
s - substitute
pattern - 查询字符串
// - 无替代文本。如果偏好,中间可以加任意字符!建议添加‘~’,重复上次查询
g - Replace all occurrences in the line. Without this argument, replacement occurs only for the first occurrence in each line.因此,如果不用此标志,就变成统计出现pattern的行数。
n - Report the number of matches, do not actually substitute.这是核心标志,也是达到目的的标志。同时也说明了为什么'//'之间可以添加任意字符!
用途
单个pattern词频统计替代方案
脚本或高级语言解析文件相关文章推荐
- vim中字符串出现次数的统计及字符创替换
- vim 查找统计一个字符串出现次数
- vim中统计字符串出现的次数
- 统计某字符串中每个字符出现的次数
- 统计字符串出现的次数
- C# 实现统计字符串中不同单词的出现次数【百度笔试题】
- 统计字符串”abadcdffbaeba”中每个字符出现了多少次,按次数排序并输出
- C++实现统计字符串出现次数
- 统计字符串出现的次数
- 搜索出字符串中出现次数最多的字符,并统计次数
- JavaScript效率PK——统计特定字符在字符串中出现的次数
- 统计字符串每个字符出现的次数
- 【shell】linux统计某一文件中字符串“sent ip”出现的次数
- javascript 统计字符串内某字符串出现次数
- 统计一个字符串在文件中出现的次数
- 统计字符串中各个字符出现的次数
- delphi中如何统计多行文本文件中相同字符串出现的次数
- 统计某字符在某字符串中出现的次数
- 统计字符串”abadcdffbaeba”中每个字符出现了多少次,按次数排序并输出
- [每周一算法]统计在一个字符串中各个不同字符出现的次数