• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            隨筆-60  評(píng)論-98  文章-0  trackbacks-0
            字符匹配

            正則表達(dá)式的關(guān)鍵之處在于確定你要搜索匹配的東西,如果沒有這一概念,Res將毫無用處。

            每一個(gè)表達(dá)式都包含需要查找的指令,如表A所示。

            Table A: Character-matching regular expressions

            操作

            解釋

            例子

            結(jié)果

            .

            Match any one character

            grep .ord sample.txt

            Will match “ford”, “l(fā)ord”, “2ord”, etc. in the file sample.txt.

            [ ]

            Match any one character listed between the brackets

            grep [cng]ord sample.txt

            Will match only “cord”, “nord”, and “gord”

            [^ ]

            Match any one character not listed between the brackets

            grep [^cn]ord sample.txt

            Will match “l(fā)ord”, “2ord”, etc. but not “cord” or “nord”

            grep [a-zA-Z]ord sample.txt

            Will match “aord”, “bord”, “Aord”, “Bord”, etc.

            grep [^0-9]ord sample.txt

            Will match “Aord”, “aord”, etc. but not “2ord”, etc.


            重復(fù)操作符

            重復(fù)操作符,或數(shù)量詞,都描述了查找一個(gè)特定字符的次數(shù)。它們常被用于字符匹配語法以查找多行的字符,可參見表B。

            Table B: Regular expression repetition operators

            操作

            解釋

            例子

            結(jié)果

            ?

            Match any character one time, if it exists

            egrep “?erd” sample.txt

            Will match “berd”, “herd”, etc. and “erd”

            *

            Match declared element multiple times, if it exists

            egrep “n.*rd” sample.txt

            Will match “nerd”, “nrd”, “neard”, etc.

            +

            Match declared element one or more times

            egrep “[n]+erd” sample.txt

            Will match “nerd”, “nnerd”, etc., but not “erd”

            {n}

            Match declared element exactly n times

            egrep “[a-z]{2}erd” sample.txt

            Will match “cherd”, “blerd”, etc. but not “nerd”, “erd”, “buzzerd”, etc.

            {n,}

            Match declared element at least n times

            egrep “.{2,}erd” sample.txt

            Will match “cherd” and “buzzerd”, but not “nerd”

            {n,N}

            Match declared element at least n times, but not more than N times

            egrep “n[e]{1,2}rd” sample.txt

            Will match “nerd” and “neerd”

            posted on 2006-10-25 16:58 創(chuàng)建更好的解決方案 閱讀(201) 評(píng)論(0)  編輯 收藏 引用

            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            蜜臀av性久久久久蜜臀aⅴ| 亚洲愉拍99热成人精品热久久| 日韩电影久久久被窝网| 国产2021久久精品| 久久伊人精品一区二区三区 | 欧美精品乱码99久久蜜桃| 欧美久久一区二区三区| 亚洲色欲久久久综合网| 国产69精品久久久久9999| 久久久久久久波多野结衣高潮| 精品久久综合1区2区3区激情| 久久ZYZ资源站无码中文动漫| 狠狠色丁香久久婷婷综合_中| 人妻无码αv中文字幕久久琪琪布| 91麻精品国产91久久久久| 久久精品一本到99热免费| 久久九色综合九色99伊人| 国产伊人久久| 国产精品美女久久久久久2018| 久久精品人妻中文系列| 久久精品无码av| 国内精品久久久久久久coent| 久久免费的精品国产V∧| 女人高潮久久久叫人喷水| 久久www免费人成精品香蕉| 久久午夜伦鲁片免费无码| 蜜桃麻豆WWW久久囤产精品| 久久国产精品二国产精品| 久久精品九九亚洲精品天堂| 久久国产精品-久久精品| 狠狠色综合网站久久久久久久高清| 久久综合给合综合久久| 国产精品久久久久久久人人看| 狠狠综合久久综合中文88| 久久婷婷国产麻豆91天堂| 日批日出水久久亚洲精品tv| 久久99精品国产麻豆蜜芽| 99久久国产综合精品网成人影院| 久久九九青青国产精品| 91精品国产综合久久香蕉| 久久93精品国产91久久综合|