Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在一个文件中有很多单词 [MM]。
我运行了这个命令:
cat file.txt | tr " " "\n"| sort | uniq > uniq.out
我发现有很多中文单词和一些字母数字和特殊字符
我想得到所有只是英语的单词 [AZ][az] ONLY
grep -E "[A-Za-z]" uniq.out | grep -Ev "[0-9]" | less
上面的命令也匹配字母数字单词。
有什么建议么 ?
谢谢!
采用
^[A-Za-z]+$
(您的正则表达式只是说它必须包含 1 个 az 字符才能使该行算作匹配)