亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

Chinaunix

標(biāo)題: awk包含匹配正則表達(dá)式問題 [打印本頁]

作者: mgqw    時間: 2012-04-19 16:13
標(biāo)題: awk包含匹配正則表達(dá)式問題
本帖最后由 mgqw 于 2012-04-19 16:15 編輯

為什么我直接匹配兩個'+'號 /^\+\+/ 能匹配上,
而用正則表達(dá)式 /^\+{2,}/ 匹配兩次以上就匹配不上了,
為什么呢? 求解釋
  1. $ cat svn.log
  2. +++ xxxconfig.js
  3. +               'xxxSettingInfo'         
  4. +               'xxxChangeSet'           
  5. +++ yyyconfig.js
  6. +               'yyySettingInfo'
  7. +               'yyyChangeSet'

  8. $
  9. $
  10. $ awk '{ if($1~/^\+\+/){print $0} }' ./svn.log  
  11. +++ xxxconfig.js
  12. +++ yyyconfig.js
  13. $
  14. $
  15. $
  16. $ awk '{ if($1~/^\+{2,}/){print $0} }' ./svn.log
  17. $
  18. $
  19. $
復(fù)制代碼

作者: waker    時間: 2012-04-19 16:17
Interval expressions were not traditionally available in awk. They were added as part of the POSIX standard to make awk and egrep consistent with each other.

Initially, because old programs may use ‘{’ and ‘}’ in regexp constants, gawk did not match interval expressions in regexps.
作者: mgqw    時間: 2012-04-19 16:28
回復(fù) 2# waker


    版主威武, 這么快就回答了!~
作者: justlooks    時間: 2012-04-19 16:30
# echo "+++ abc"|awk --posix '/^\+{2,}/'
+++ abc

作者: waker    時間: 2012-04-19 16:32
說明你發(fā)了個經(jīng)帖
作者: mgqw    時間: 2012-04-19 16:36
我有罪......
作者: mpstat    時間: 2012-04-19 16:40
       r{n,m}     One or two numbers inside braces denote an interval expression.  If there is one number in the braces, the preceding regular  expression
                  r is repeated n times.  If there are two numbers separated by a comma, r is repeated n to m times.  If there is one number followed by a
                  comma, then r is repeated at least n times.
                  Interval expressions are only available if either --posix or --re-interval is specified on the command line.
作者: yjcdoc    時間: 2012-04-19 17:44
用--re-interval 參數(shù)可以




歡迎光臨 Chinaunix (http://www.72891.cn/) Powered by Discuz! X3.2