byterat

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            54 隨筆 :: 0 文章 :: 15 評論 :: 0 Trackbacks

          Expression Description
          \t       Tab字符
          \n       新行
          .        匹配任意字符
          |        匹配"左邊和右邊"的字符串, 例如: "ac|ad" 匹配 "ac" 和 "ad"
          []       匹配所有在 符號"[]"閉合區間內 的任意字符, 例如: "[ab]" matches "a" and "b". "[0-9]" matches any digit.
          [^]      匹配所有不在  符號"[]"閉合區間內  的任意字符, 例如: "[^ab]" 匹配所有除了"a"和"b"之外的字符, "[^0-9]" 匹配所有非數字字符
          *        匹配符號"*"的左邊字符(0次或多次) 例如:"be*" 匹配 "b", "be" , "bee"
          +        匹配符號"+"的左邊字符(1次或多次) 例如:"be+" 匹配 "be" and "bee", 但不匹配 "b"
          ?        匹配符號"?"的左邊字符(0次或1次) 例如:be?" 匹配 "b" 和 "be", 但不匹配 "bee"
          ^        匹配符號"^"的右邊字符串, 并且該字符串必須在行首, 例如: ^AB 匹配字符串"AB",并且該"AB"必須在行首
          $        匹配符號"$"的左邊字符串, 并且該字符串必須在行尾, 例如: AB$ 匹配字符串"AB",并且該"AB"必須在行尾
          ()       Affects evaluation order of expression and also used for tagged expression.
          \        Escape character. If you want to use character "\" itself, you should use "\\".


          技巧:
          1. 查找空行 : "^[ \t]*\n"
          2. 查找行首序號: "^[0-9. ]+"
             例如: 
             "
                1. aaaa
                2. bbbb
                :
                100. abcd
                :
             "
          3. 查找"["和"]"之間的內容: "\[.+\]"
          4. 匹配<b></b>之間的內容(包括<b></b>):"^\<b\>.+\</b\>"
          5. 匹配<b>...<br/>之間沒有"/"字符的內容:"^\<b\>[^/]+\<br/\>"
             例如:
                ...
                <b>appeal</b> - v. to take to <br/>
                <b>somebody for help <br/>
                <b>appoint</b> - v. to name;<br/>
                <b>statues <br/>
                ...
                
                使用:^(\<b\>)([^/]+\<br/\>) 和替換串"\2", 將使得以上的第2行和第4行變成:
                ...
                <b>appeal</b> - v. to take to <br/>
                somebody for help <br/>
                <b>appoint</b> - v. to name;<br/>
                statues <br/>
                ...

          The tagged expression is enclosed by (). Tagged expressions can be referenced by \0, \1, \2, \3, etc. \0 indicates a tagged expression representing the entire substring that was matched. \1 indicates the first tagged expression, \2 is the second, etc. See following examples.

          Original Search  Replace  Result 
          abc      (ab)(c) \0-\1-\2 abc-ab-c
          abc      a(b)(c) \0-\1-\2 abc-b-c
          abc      (a)b(c) \0-\1-\2 abc-a-c

          posted on 2006-12-20 18:18 比特鼠 閱讀(483) 評論(0)  編輯  收藏 所屬分類: Tools

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 科尔| 拜城县| 集安市| 迭部县| 儋州市| 正定县| 崇仁县| 佛山市| 扶绥县| 汉阴县| 新余市| 南澳县| 石首市| 永顺县| 富顺县| 香格里拉县| 嵊州市| 喀喇沁旗| 孝感市| 永春县| 古丈县| 三明市| 鄂托克前旗| 乳山市| 锡林郭勒盟| 东乡族自治县| 同心县| 梧州市| 新余市| 西贡区| 鱼台县| 达拉特旗| 炉霍县| 顺昌县| 绿春县| 民丰县| 通许县| 阳东县| 黄龙县| 丽江市| 乌审旗|