• <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)  編輯 收藏 引用
            久久久无码精品亚洲日韩蜜臀浪潮 | 狠狠色丁香久久婷婷综合蜜芽五月 | 久久香蕉一级毛片| 国产—久久香蕉国产线看观看| 久久综合狠狠综合久久激情 | 国产视频久久| 久久丫精品国产亚洲av| 久久精品一区二区影院| 天天躁日日躁狠狠久久| 九九久久精品国产| 久久久无码人妻精品无码| 色天使久久综合网天天| 久久精品国产99国产精偷| 久久天天婷婷五月俺也去| 99久久国产综合精品网成人影院 | 亚洲精品无码久久久| 欧美亚洲国产精品久久蜜芽| 久久中文字幕人妻熟av女| 94久久国产乱子伦精品免费| 亚洲精品美女久久777777| 久久人妻少妇嫩草AV无码蜜桃| 国产精品久久久久影院嫩草| 亚洲中文字幕无码久久综合网| 久久精品国产色蜜蜜麻豆| 亚洲一区中文字幕久久| 韩国三级大全久久网站| 丰满少妇人妻久久久久久| 久久久久久久久波多野高潮| 麻豆国内精品久久久久久| 国产精品九九久久精品女同亚洲欧美日韩综合区| 久久婷婷五月综合国产尤物app | 久久久久久毛片免费看| 国产精品99久久久久久猫咪| 久久综合九色综合欧美狠狠| 久久综合九色综合网站| 久久久久久久久无码精品亚洲日韩 | 国产综合免费精品久久久| 99久久精品午夜一区二区| 久久免费的精品国产V∧| 亚洲国产精品一区二区久久hs| 亚洲乱码精品久久久久..|