• <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  評論-98  文章-0  trackbacks-0
            字符匹配

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

            每一個表達式都包含需要查找的指令,如表A所示。

            Table A: Character-matching regular expressions

            操作

            解釋

            例子

            結果

            .

            Match any one character

            grep .ord sample.txt

            Will match “ford”, “lord”, “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 “lord”, “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.


            重復操作符

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

            Table B: Regular expression repetition operators

            操作

            解釋

            例子

            結果

            ?

            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 創建更好的解決方案 閱讀(205) 評論(0)  編輯 收藏 引用
            97精品伊人久久久大香线蕉| 日产精品久久久久久久| 久久99久久无码毛片一区二区| 欧美亚洲国产精品久久| 国内精品久久久久久久久| 久久久久亚洲AV综合波多野结衣 | 无码国内精品久久人妻| 青青热久久国产久精品| 国内精品久久久久久麻豆 | 久久se精品一区精品二区国产 | 97久久精品无码一区二区 | 一本久久综合亚洲鲁鲁五月天| 91久久精品无码一区二区毛片| 亚洲欧美国产精品专区久久| 99久久国产热无码精品免费| 99国产精品久久久久久久成人热| 国产亚州精品女人久久久久久| 久久亚洲精品成人av无码网站| 欧美大战日韩91综合一区婷婷久久青草| 国产精品免费福利久久| 一本色道久久88精品综合| 要久久爱在线免费观看| 国产成人无码精品久久久免费| 无码AV波多野结衣久久| 香蕉久久AⅤ一区二区三区| 国产精品成人99久久久久91gav| 麻豆一区二区99久久久久| 伊人久久综合精品无码AV专区| 久久强奷乱码老熟女| 久久99国产一区二区三区| 久久免费精品视频| 一97日本道伊人久久综合影院| 久久强奷乱码老熟女网站| 久久久久亚洲精品男人的天堂| 激情五月综合综合久久69| 91精品国产91久久久久久青草| 久久本道伊人久久| 久久亚洲sm情趣捆绑调教 | 久久久久无码专区亚洲av| 97久久天天综合色天天综合色hd| 99久久精品日本一区二区免费 |