• <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)  編輯 收藏 引用
            狠狠色婷婷综合天天久久丁香| 天天久久狠狠色综合| 久久午夜免费视频| 久久影院久久香蕉国产线看观看| 久久亚洲精品国产精品| 青青草国产精品久久| 欧美粉嫩小泬久久久久久久 | 亚洲欧美日韩中文久久| 国产99精品久久| 国产精品99久久久精品无码| 伊人久久精品线影院| 久久综合国产乱子伦精品免费| a级毛片无码兔费真人久久| 久久中文骚妇内射| 久久亚洲国产精品五月天婷| 久久精品国产亚洲AV嫖农村妇女| 久久久久久一区国产精品| 潮喷大喷水系列无码久久精品| 亚洲精品无码久久久久AV麻豆| 伊人色综合久久| 国产成人精品免费久久久久| 久久久久久人妻无码| 九九精品99久久久香蕉| 7777久久久国产精品消防器材| 久久久久亚洲AV无码专区网站| 天天爽天天狠久久久综合麻豆| 久久精品国产精品亜洲毛片| 久久久久免费看成人影片| 麻豆av久久av盛宴av| 免费精品久久久久久中文字幕| 久久www免费人成精品香蕉| 91亚洲国产成人久久精品| 久久99国产精品久久99| 精品久久久久久国产| 久久久青草久久久青草| 老司机国内精品久久久久| 久久天堂电影网| 久久99热这里只有精品国产| 久久国产成人午夜aⅴ影院| 色99久久久久高潮综合影院 | 亚洲国产精品成人久久蜜臀|