LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 737|回复: 1

关于正则表达式的问题

[复制链接]
发表于 2005-11-27 11:31:38 | 显示全部楼层 |阅读模式
最近在学习正则表达式。昨天使用rpm -qa|grep [[:upper:]]时不小心打成了rpm -qa|grep [:upper:]。结果有一些没有大写的行也被显示出来。但我用wc -l看了一下,比rpm -qa的要少。它还是过滤了一些,那这个[:upper:]到底起了什么作用呢?看文档也没明白。希望朋友帮助我一下。
发表于 2005-11-27 15:20:15 | 显示全部楼层
Post by ibmwebzh
最近在学习正则表达式。昨天使用rpm -qa|grep [[:upper:]]时不小心打成了rpm -qa|grep [:upper:]。结果有一些没有大写的行也被显示出来。但我用wc -l看了一下,比rpm -qa的要少。它还是过滤了一些,那这个[:upper:]到底起了什么作用呢?看文档也没明白。希望朋友帮助我一下。

在[]character class set中,有一种特殊的形式叫posix character class.用[::],[..],或[==]来表示。其中,[::]表示character class.如[:upper:]表示大写字符集。要注意的是[::]必须包括在[]中。
“All three of these constructs must appear inside the square brackets of a bracket expression. For example [[:alpha:]!] matches any single alphabetic character or the exclamation point, [[.ch.]]
matches the collating element ch, but does not match just the letter c or the letter h. In a French locale, [[=e=]] might match any of e, è, or é. ”
详细的资料请参考sed&awk第二版。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表