google rss rss

          doneykoo [Ouditian]

          DKzone- Ouditian Technology

          UltraEdit 與Unix 正則表達(dá)式

          UltraEdit 允許在搜索菜單下面列出了的許多搜索和替換功能中使用正則表達(dá)式。正則表達(dá)式能讓更多的復(fù)雜的搜索和替換功能變成簡(jiǎn)單的操作。(中文版界面上顯示為“正規(guī)表達(dá)式”)

          有兩個(gè)可使用的語(yǔ)法集合。下面的第一表顯示出在 UltraEdit 的更早的版本被使用的原來(lái)的 UltraEdit 句法。第二表給出了可選的"Unix"類型的正則表達(dá)式。這可以從配置單元啟用。

           

          符號(hào)  功能

          %     匹配行的開(kāi)始 - 顯示搜索字符串必須在行的開(kāi)始,但是在所選擇的結(jié)果字符串中不包括任何行終止字符。

          $     匹配行尾 - 顯示搜索字符串必須在行尾,但是在所選擇的結(jié)果字符串中不包括任何行終止字符。

          ?     除了換行符以外匹配任何單個(gè)的字符

          *     除了換行符匹配任何數(shù)量的字符和數(shù)字

          +     前一字符匹配一個(gè)或多個(gè),但至少要出現(xiàn)一個(gè)

          ++    前一字符匹配零個(gè)或多個(gè),但至少要出現(xiàn)一個(gè)

          ^b    匹配一個(gè)分頁(yè)

          ^p    匹配一個(gè)換行符(CR/LF)()(DOS文件)

          ^r    匹配一個(gè)換行符(CR 僅僅)()(MAC 文件)

          ^n    匹配一個(gè)換行符 ( LF 僅僅 )( )( UNIX 文件 )

          ^t    匹配一個(gè)標(biāo)簽字符TAB

          []    匹配任何單個(gè)的字符,或在方括號(hào)中的范圍

          ^{A^}^{ B^} 匹配表達(dá)式A B

          ^     重載其后的正規(guī)表達(dá)式字符

          ^(^)  括或標(biāo)注為用于替換命令的表達(dá)式。

           

          一個(gè)正則表達(dá)式最多可以有9個(gè)標(biāo)注表達(dá)式, 按正規(guī)表達(dá)式的需要而定。

          相應(yīng)的替換表達(dá)式是 ^x , 替換范圍x1-9。例如:

          If ^(h*o^) ^(f*s^) matches "hello folks",

          ^2 ^1 would replace it with "folks hello".

           

          hello folks 將被替換成 folks hello。)

           

          注: ^ 是實(shí)際字符 ^不是Ctl + 鍵值。

           

          例如:

          m?n 匹配 "man","men","min" 但不匹配 "moon".

          t*t 匹配 "test","tonight" "tea time" (the "tea t" portion) 但不匹配 "tea

          time" (newline between "tea " and "time").

          Te+st 匹配 "test","teest"," teeeest "等等。但是不匹配 "tst"

          [aeiou]  匹配每個(gè)小寫元音。

          [,.?]  匹配一文字的 ",""." "?"

          [0-9, a-z] 匹配任何數(shù)位,或小寫字母。

          [~0-9] 除了數(shù)字以外匹配任何字符 (~ 意味著"")

           

          你按如下方式可以查找一個(gè)表達(dá)式A B

           

          "^{John^}^{Tom^}"

           

          這將在找JohnTom的出現(xiàn)。應(yīng)該在 2 個(gè)表達(dá)式之間沒(méi)有任何東西。

           

          你可以在同一搜索中按如下方式組合A or B and C or D

           

          "^{John^}^{Tom^}^{Smith^}^{Jones^}"

           

          這將在John or Tom 后面找 Smith or Jones

           

           

          下表為"Unix"句法類型的正則表達(dá)式。

           

          正則表達(dá)式 (Unix句法)

           

          符號(hào)        功能

                    標(biāo)記下一個(gè)字符作為一個(gè)特殊的字符。

          "n"         匹配字符"n""n" 一個(gè)換行符或換行符字符。

          ^           匹配/定位行的開(kāi)始。

          $           匹配/定位行的尾。

          *           匹配前面的字符零次或多次。例

          +           匹配前面的字符一次或多次。例

          .           匹配除了一個(gè)換行符字符匹配任何單個(gè)的字符。

          (expression)標(biāo)注用于替換命令的表達(dá)式。一個(gè)正則表達(dá)式根據(jù)需要,最多可以有9個(gè)標(biāo)注表達(dá)式。相應(yīng)的代替表達(dá)式是 x , x的范圍是 1-9

           

           

          例如:

           

          If (h.*o) (f.*s) matches "hello folks",

          2 1 would replace it with "folks hello".

          hello folks 將被替換成 folks hello。)

           

           

          [xyz]       一個(gè)字符集。匹配在方括號(hào)之間的任何字符。

          [^xyz]      一個(gè)否定的字符集。不匹配在方括號(hào)之間的任何字符。

          d          匹配一個(gè)數(shù)字字符。等價(jià)于[0-9]

          D          匹配一個(gè)非數(shù)字字符。等價(jià)于[^0-9]

          f          匹配一個(gè)換頁(yè)字符。

          n          匹配一個(gè)換行字符。

          r          匹配一個(gè)回車符字符。

          s          匹配任何空白的空格, 標(biāo)簽, 換頁(yè), 包括空格等等,但不匹配換行符。

          S          匹配任何非空白的字符,但不匹配換行符。

          t          匹配一個(gè)標(biāo)簽TAB字符。

          v          匹配一個(gè)垂直的標(biāo)簽字符。

          w          匹配任何詞語(yǔ)字符包括下劃線。

          W          匹配任何非詞語(yǔ)字符字符。

           

          注: ^ 是實(shí)際字符 ^不是Ctl + 鍵值。

           

           

          例如:

          m.n       匹配 "man","men","min" 但不匹配 "moon".

          t+t       匹配 "test","tonight" "tea time" (the "tea t" portion) 但不匹配 "tea

          time" (newline between "tea " and "time").

          Te*st     匹配 "test","teest"," teeeest "等等。但是不匹配 "tst"

          [aeiou]   匹配每個(gè)小寫元音。

          [,.?]     匹配一文字的 ",""." "?"

          [0-9,a-z] 匹配任何數(shù)位,或小寫字母。

          [^0-9]    除了數(shù)字以外匹配任何字符 (~ 意味著"")

           

           

          你按如下方式可以查找一個(gè)表達(dá)式A B

           

          "(John)|(Tom)"

           

          這將在找JohnTom的出現(xiàn)。應(yīng)該在 2 個(gè)表達(dá)式之間沒(méi)有任何東西。

           

          你可以在同一搜索中按如下方式組合A or B and C or D

           

          "(John|Tom) (Smith|Jones)"

           

          這將在John or Tom 后面找 Smith or Jones

           

           

          另外:

           

          p        匹配 CR/LF ( 作為 rn 的一樣 ) 作為DOS行結(jié)束符匹配

           

          如果查找/替換功能中正則表達(dá)式?jīng)]有選用,則替換字段中下列字符也是有效的:

           

          符號(hào)   功能

           

          ^^          匹配一個(gè) "^" 字符

          ^s          替換為被選擇 ( 加亮 ) 活躍的文件窗口的文章。

          ^c          替換為剪貼板的內(nèi)容

          ^b          匹配一個(gè)頁(yè)裂縫

          ^p          匹配一個(gè)換行符 ( CR/LF )( )( DOS 文件)

          ^r          匹配一個(gè)換行符 ( CR 僅僅 )( )( MAC 文件)

          ^n          匹配一個(gè)換行符 ( LF 僅僅 )( )( UNIX 文件)

          ^t          匹配一個(gè)標(biāo)簽TAB字符

          Regular Expressions

           

          UltraEdit allows for Regular Expressions in many of its search and

          replace functions listed under the Search Menu.

           

          Regular expressions allow more complex search and replace functions

          to be performed in a single operation.

           

          There are two possible sets of syntax that may be used.  The first

          table below shows the original UltraEdit syntax used in earlier

          versions of UltraEdit.  The second table shows the optional "Unix"

          style regular expressions.  This may be enabled from the

          Configuration Section.

           

          Regular Expressions (UltraEdit Syntax):

           

          Symbol

           Function

           

          %

           Matches the start of line - Indicates the search string must be at

          the beginning of a line but does not include any line terminator

          characters in the resulting string selected.

           

          $

           Matches the end of line - Indicates the search string must be at the

          end of line but does not include any line terminator characters in

          the resulting string selected.

           

          ?

           Matches any single character except newline.

           

          *

           Matches any number of occurrences of any character except newline.

           

          +

           Matches one or more of the preceding character/expression.  At least

          one occurrence of the character must be found.  Does not match

          repeated newlines.

           

          ++

           Matches the preceding character/expression zero or more times.  Does

          not match repeated newlines.

           

          ^b

           Matches a page break.

           

          ^p

           Matches a newline (CR/LF) (paragraph) (DOS Files)

           

          ^r

           Matches a newline (CR Only) (paragraph) (MAC Files)

           

          ^n

           Matches a newline (LF Only) (paragraph) (UNIX Files)

           

          ^t

           Matches a tab character

           

          [ ]

           Matches any single character or range in the brackets

           

          ^{A^}^{B^}

           Matches expression A OR B

           

          ^

           Overrides the following regular expression character

           

          ^(區(qū))  

           Brackets or tags an expression to use in the replace command.  A

          regular expression may have up to 9 tagged expressions, numbered

          according to their order in the regular expression.

           

          The corresponding replacement expression is ^x, for x in the range

          1-9.  Example: If ^(h*o^) ^(f*s^) matches "hello folks", ^2 ^1 would

          replace it with "folks hello".

           

           

          Note - ^ refers to the character '^' NOT Control Key + value.

           

          Examples:

          m?n matches "man", "men", "min" but not "moon".

           

          t*t matches "test", "tonight" and "tea time" (the "tea t" portion)

          but not "tea

          time" (newline between "tea " and "time").

           

          Te+st matches "test", "teest", "teeeest" etc. but does not match

          "tst".

           

          [aeiou] matches every lowercase vowel

          [,.?] matches a literal ",", "." or "?".

          [0-9a-z] matches any digit, or lowercase letter

          [~0-9] matches any character except a digit (~ means NOT the

          following)

           

          You may search for an expression A or B as follows:

           

          "^{John^}^{Tom^}?/SPAN>

           

          This will search for an occurrence of John or Tom.  There should be

          nothing between the two expressions.

           

          You may combine A or B and C or D in the same search as follows:

           

          "^{John^}^{Tom^} ^{Smith^}^{Jones^}"

           

          This will search for John or Tom followed by Smith or Jones.

           

          The table below shows the syntax for the "Unix" style regular

          expressions.

           

          Regular Expressions (Unix Syntax):

           

          Symbol

           Function

           

          \

           Indicates the next character has a special meaning. "n" on it own

          matches the character "n". "\n" matches a linefeed or newline

          character.  See examples below (\d, \f, \n etc).

           

          ^

           Matches/anchors the beginning of line.

           

          $

           Matches/anchors the end of line.

           

          *

           Matches the preceding character zero or more times.

           

          +

           Matches the preceding character one or more times. Does not match

          repeated newlines.

           

          .

           Matches any single character except a newline character. Does not

          match repeated newlines.

           

          (expression)

           Brackets or tags an expression to use in the replace command.A

          regular expression may have up to 9 tagged expressions, numbered

          according to their order in the regular expression.

           

          The corresponding replacement expression is \x, for x in the range

          1-9.  Example: If (h.*o) (f.*s) matches "hello folks", \2 \1 would

          replace it with "folks hello".

           

          [xyz]

           A character set. Matches any characters between brackets.

           

          [^xyz]

           A negative character set. Matches any characters NOT between

          brackets.

           

          \d

           Matches a digit character. Equivalent to [0-9].

           

          \D

           Matches a nondigit character. Equivalent to [^0-9].

           

          \f

           Matches a form-feed character.

           

          \n

           Matches a linefeed character.

           

          \r

           Matches a carriage return character.

           

          \s

           Matches any whitespace including space, tab, form-feed, etc but not

          newline.

           

          \S

           Matches any non-whitespace character but not newline.

           

          \t

           Matches a tab character.

           

          \v

           Matches a vertical tab character.

           

          \w

           Matches any word character including underscore.

           

          \W

           Matches any nonword character.

           

          \p

           Matches CR/LF (same as \r\n) to match a DOS line terminator

           

           

          Note - ^ refers to the character '^' NOT Control Key + value.

           

          Examples:

          m.n matches "man", "men", "min" but not "moon".

           

          Te+st matches "test", "teest", "teeeest" etc. BUT NOT "tst".

           

          Te*st matches "test", "teest", "teeeest" etc. AND "tst".

           

          [aeiou] matches every lowercase vowel

          [,.?] matches a literal ",", "." or "?".

          [0-9a-z] matches any digit, or lowercase letter

          [^0-9] matches any character except a digit (^ means NOT the

          following)

           

          You may search for an expression A or B as follows:

           

          "(John|Tom)"

           

          This will search for an occurrence of John or Tom.  There should be

          nothing between the two expressions.

           

          You may combine A or B and C or D in the same search as follows:

           

          "(John|Tom) (Smith|Jones)"

           

           

          This will search for John or Tom followed by Smith or Jones.

           

          If Regular Expression is not selected for the find/replace and in the

          Replace field the following special characters are also valid:

           

          Symbol

           Function

           

          ^^

           Matches a "^" character

           

          ^s

           Is substituted with the selected (highlighted) text of the active

          file window.

           

          ^c

           Is substituted with the contents of the clipboard.

           

          ^b

           Matches a page break

           

          ^p

           Matches a newline (CR/LF) (paragraph) (DOS Files)

           

          ^r

           Matches a newline (CR Only) (paragraph) (MAC Files)

           

          ^n

           Matches a newline (LF Only) (paragraph) (UNIX Files)

           

          ^t

           Matches a tab character

           

           

          Note - ^ refers to the character '^' NOT Control Key + value. 

           

          Pasted from <http://www.niwota.com/submsg/1966636/>

           

          posted on 2009-10-13 18:36 DoNeY 閱讀(1713) 評(píng)論(0)  編輯  收藏


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
            doneykoo blogjava
            
          主站蜘蛛池模板: 临湘市| 大关县| 兖州市| 大足县| 西华县| 两当县| 利辛县| 雅江县| 克什克腾旗| 海门市| 永福县| 毕节市| 精河县| 高清| 德令哈市| 同心县| 崇信县| 永登县| 凤庆县| 望谟县| 永城市| 桦甸市| 酉阳| 庆城县| 株洲县| 黑龙江省| 繁昌县| 涞水县| 东莞市| 鄂托克前旗| 怀安县| 临澧县| 巴彦淖尔市| 二手房| 郧西县| 改则县| 永登县| 建瓯市| 石城县| 梁平县| 湄潭县|