Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1615436
  • 博文数量: 409
  • 博客积分: 6240
  • 博客等级: 准将
  • 技术积分: 4908
  • 用 户 组: 普通用户
  • 注册时间: 2011-06-01 00:04
文章分类

全部博文(409)

文章存档

2021年(1)

2019年(1)

2017年(1)

2016年(13)

2015年(22)

2013年(4)

2012年(240)

2011年(127)

分类: Python/Ruby

2012-02-29 16:10:44

1.从百度百科查看到:
  1. {i}
  2. {i,j} 匹配指定数目的字符,这些字符是在它之前的表达式定义的。例如正则表达式A[0-9]{3} 能够匹配字符"A"后面跟着正好3个数字字符的串,例如A123、A348等,但是不匹配A1234。而正则表达式[0-9]{4,6} 匹配连续的任意4个、5个或者6个数字字符。注意:这个元字符不是所有的软件都支持的。
2.测试:
  1. [yangkai@admin awkdir]$ cat filea |awk '/[0-9]{3,}/'
  2. [yangkai@admin awkdir]$ cat filea |awk --re '/[0-9]{3,}/'
  3. 10/05766798607,11/20050325191329,29/0.1,14/05766798607
  4. 10/05767158557,11/20050325191329,29/0.08,14/05767158557
  5. [yangkai@admin awkdir]$ grep "[0-9]{5}"
  6. [yangkai@admin awkdir]$ grep "[0-9]{5}" filea
  7. [yangkai@admin awkdir]$ egrep "[0-9]{5}" filea
  8. 10/05766798607,11/20050325191329,29/0.1,14/05766798607
  9. 10/05767158557,11/20050325191329,29/0.08,14/05767158557
  10. [yangkai@admin awkdir]$ grep -E "[0-9]{5}" filea
  11. 10/05766798607,11/20050325191329,29/0.1,14/05766798607
  12. 10/05767158557,11/20050325191329,29/0.08,14/05767158557
  13. [yangkai@admin awkdir]$
3.man awk:
  1. -W re-interval
  2. --re-interval
  3. Enable the use of interval expressions in regular expression matching (see Regular Expressions, below).
  4. Interval expressions were not traditionally available in the AWK language. The POSIX standard added them, to
  5. make awk and egrep consistent with each other. However, their use is likely to break old AWK programs, so
  6. gawk only provides them if they are requested with this option, or when --posix is specified.
4.不是所有软件都适用。。。




阅读(1813) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~