• <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 創建更好的解決方案 閱讀(200) 評論(0)  編輯 收藏 引用
            91麻豆精品国产91久久久久久| 国产精品美女久久久网AV| 亚洲国产视频久久| 久久国产劲爆AV内射—百度| 99久久国语露脸精品国产| 精品无码久久久久久久动漫| 99久久国产综合精品女同图片| 久久精品成人国产午夜| 国产精品久久久久免费a∨| 久久99国产精一区二区三区| 久久人人爽人人澡人人高潮AV | 久久99久久成人免费播放| 久久亚洲国产最新网站| 九九久久精品国产| 久久亚洲精品成人av无码网站| 久久免费小视频| 欧美丰满熟妇BBB久久久| 日本福利片国产午夜久久| 亚洲精品无码久久毛片| 久久综合九色综合精品| 久久久久亚洲AV无码观看| 久久精品国产亚洲AV不卡| 国产精品久久久亚洲| 久久久久久精品免费免费自慰 | 亚洲а∨天堂久久精品| 99久久伊人精品综合观看| 久久精品国产亚洲AV无码麻豆| 久久亚洲AV成人无码| 久久亚洲国产精品123区| 国内精品久久久久久不卡影院 | 香港aa三级久久三级老师2021国产三级精品三级在 | 久久亚洲国产成人精品性色| 久久AV无码精品人妻糸列| 久久天天躁狠狠躁夜夜不卡| 国産精品久久久久久久| 国产叼嘿久久精品久久| 国产精品99久久久久久董美香 | 久久狠狠爱亚洲综合影院 | 久久免费99精品国产自在现线| 91精品国产色综久久| 国产99久久久久久免费看|