posts - 19, comments - 1, trackbacks - 0, articles - 0
            BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

          2006年10月7日

          正則表達(dá)式是煩瑣的,但是強(qiáng)大的,學(xué)會(huì)之后的應(yīng)用會(huì)讓你除了提高效率外,會(huì)給你帶來(lái)絕對(duì)的成就感。只要認(rèn)真去閱讀這些資料,加上應(yīng)用的時(shí)候進(jìn)行一定的參考,掌握正則表達(dá)式不是問(wèn)題。

          索引

          1. 引子
          2. 正則表達(dá)式的歷史
          3. 正則表達(dá)式定義

          3.1 普通字符
          3.2 非打印字符
          3.3 特殊字符
          3.4 限定符
          3.5 定位符
          3.6 選擇
          3.7 后向引用

          4. 各種操作符的運(yùn)算優(yōu)先級(jí)
          5. 全部符號(hào)解釋
          6. 部分例子
          7. 正則表達(dá)式匹配規(guī)則

          7.1 基本模式匹配
          7.2 字符簇
          7.3 確定重復(fù)出現(xiàn)

          1. 引子
            目前,正則表達(dá)式已經(jīng)在很多軟件中得到廣泛的應(yīng)用,包括*nix(Linux, Unix等),HP等操作系統(tǒng),PHP,C#,Java等開(kāi)發(fā)環(huán)境,以及很多的應(yīng)用軟件中,都可以看到正則表達(dá)式的影子。

            正則表達(dá)式的使用,可以通過(guò)簡(jiǎn)單的辦法來(lái)實(shí)現(xiàn)強(qiáng)大的功能。為了簡(jiǎn)單有效而又不失強(qiáng)大,造成了正則表達(dá)式代碼的難度較大,學(xué)習(xí)起來(lái)也不是很容易,所以需要付出一些努力才行,入門(mén)之后參照一定的參考,使用起來(lái)還是比較簡(jiǎn)單有效的。

          例子: ^.+@.+\\..+$

            這樣的代碼曾經(jīng)多次把我自己給嚇退過(guò)。可能很多人也是被這樣的代碼給嚇跑的吧。繼續(xù)閱讀本文將讓你也可以自由應(yīng)用這樣的代碼。

            注意:這里的第7部分跟前面的內(nèi)容看起來(lái)似乎有些重復(fù),目的是把前面表格里的部分重新描述了一次,目的是讓這些內(nèi)容更容易理解。

          2. 正則表達(dá)式的歷史
            正則表達(dá)式的“祖先”可以一直上溯至對(duì)人類(lèi)神經(jīng)系統(tǒng)如何工作的早期研究。Warren McCulloch 和 Walter Pitts 這兩位神經(jīng)生理學(xué)家研究出一種數(shù)學(xué)方式來(lái)描述這些神經(jīng)網(wǎng)絡(luò)。
            1956 年, 一位叫 Stephen Kleene 的數(shù)學(xué)家在 McCulloch 和 Pitts 早期工作的基礎(chǔ)上,發(fā)表了一篇標(biāo)題為“神經(jīng)網(wǎng)事件的表示法”的論文,引入了正則表達(dá)式的概念。正則表達(dá)式就是用來(lái)描述他稱(chēng)為“正則集的代數(shù)”的表達(dá)式,因此采用“正則表達(dá)式”這個(gè)術(shù)語(yǔ)。

            隨后,發(fā)現(xiàn)可以將這一工作應(yīng)用于使用 Ken Thompson 的計(jì)算搜索算法的一些早期研究,Ken Thompson 是 Unix 的主要發(fā)明人。正則表達(dá)式的第一個(gè)實(shí)用應(yīng)用程序就是 Unix 中的 qed 編輯器。

            如他們所說(shuō),剩下的就是眾所周知的歷史了。從那時(shí)起直至現(xiàn)在正則表達(dá)式都是基于文本的編輯器和搜索工具中的一個(gè)重要部分。

           

          3. 正則表達(dá)式定義
            正則表達(dá)式(regular expression)描述了一種字符串匹配的模式,可以用來(lái)檢查一個(gè)串是否含有某種子串、將匹配的子串做替換或者從某個(gè)串中取出符合某個(gè)條件的子串等。

          列目錄時(shí), dir *.txt或ls *.txt中的*.txt就不是一個(gè)正則表達(dá)式,因?yàn)檫@里*與正則式的*的含義是不同的。
            正則表達(dá)式是由普通字符(例如字符 a 到 z)以及特殊字符(稱(chēng)為元字符)組成的文字模式。正則表達(dá)式作為一個(gè)模板,將某個(gè)字符模式與所搜索的字符串進(jìn)行匹配。

          3.1 普通字符
            由所有那些未顯式指定為元字符的打印和非打印字符組成。這包括所有的大寫(xiě)和小寫(xiě)字母字符,所有數(shù)字,所有標(biāo)點(diǎn)符號(hào)以及一些符號(hào)。

          3.2 非打印字符
          字符 含義
          \cx 匹配由x指明的控制字符。例如, \cM 匹配一個(gè) Control-M 或回車(chē)符。x 的值必須為 A-Z 或 a-z 之一。否則,將 c 視為一個(gè)原義的 ‘c’ 字符。
          \f 匹配一個(gè)換頁(yè)符。等價(jià)于 \x0c 和 \cL。
          \n 匹配一個(gè)換行符。等價(jià)于 \x0a 和 \cJ。
          \r 匹配一個(gè)回車(chē)符。等價(jià)于 \x0d 和 \cM。
          \s 匹配任何空白字符,包括空格、制表符、換頁(yè)符等等。等價(jià)于 [ \f\n\r\t\v]。
          \S 匹配任何非空白字符。等價(jià)于 [^ \f\n\r\t\v]。
          \t 匹配一個(gè)制表符。等價(jià)于 \x09 和 \cI。
          \v 匹配一個(gè)垂直制表符。等價(jià)于 \x0b 和 \cK。

           
          3.3 特殊字符
            所謂特殊字符,就是一些有特殊含義的字符,如上面說(shuō)的”*.txt”中的*,簡(jiǎn)單的說(shuō)就是表示任何字符串的意思。如果要查找文件名中有*的文件,則需要對(duì)*進(jìn)行轉(zhuǎn)義,即在其前加一個(gè)\。ls \*.txt。正則表達(dá)式有以下特殊字符。
           

          特別字符 說(shuō)明
          $ 匹配輸入字符串的結(jié)尾位置。如果設(shè)置了 RegExp 對(duì)象的 Multiline 屬性,則 $ 也匹配 ‘\n’ 或 ‘\r’。要匹配 $ 字符本身,請(qǐng)使用 \$。
          ( ) 標(biāo)記一個(gè)子表達(dá)式的開(kāi)始和結(jié)束位置。子表達(dá)式可以獲取供以后使用。要匹配這些字符,請(qǐng)使用 \( 和 \)。
          * 匹配前面的子表達(dá)式零次或多次。要匹配 * 字符,請(qǐng)使用 \*。
          + 匹配前面的子表達(dá)式一次或多次。要匹配 + 字符,請(qǐng)使用 \+。
          . 匹配除換行符 \n之外的任何單字符。要匹配 .,請(qǐng)使用 \。
          [ 標(biāo)記一個(gè)中括號(hào)表達(dá)式的開(kāi)始。要匹配 [,請(qǐng)使用 \[。
          ? 匹配前面的子表達(dá)式零次或一次,或指明一個(gè)非貪婪限定符。要匹配 ? 字符,請(qǐng)使用 \?。
          \ 將下一個(gè)字符標(biāo)記為或特殊字符、或原義字符、或向后引用、或八進(jìn)制轉(zhuǎn)義符。例如, ‘n’ 匹配字符 ‘n’。’\n’ 匹配換行符。序列 ‘\\’ 匹配 “\”,而 ‘\(’ 則匹配 “(”。
          ^ 匹配輸入字符串的開(kāi)始位置,除非在方括號(hào)表達(dá)式中使用,此時(shí)它表示不接受該字符集合。要匹配 ^ 字符本身,請(qǐng)使用 \^。
          { 標(biāo)記限定符表達(dá)式的開(kāi)始。要匹配 {,請(qǐng)使用 \{。
          | 指明兩項(xiàng)之間的一個(gè)選擇。要匹配 |,請(qǐng)使用 \|。

            構(gòu)造正則表達(dá)式的方法和創(chuàng)建數(shù)學(xué)表達(dá)式的方法一樣。也就是用多種元字符與操作符將小的表達(dá)式結(jié)合在一起來(lái)創(chuàng)建更大的表達(dá)式。正則表達(dá)式的組件可以是單個(gè)的字符、字符集合、字符范圍、字符間的選擇或者所有這些組件的任意組合。
           

          3.4 限定符
            限定符用來(lái)指定正則表達(dá)式的一個(gè)給定組件必須要出現(xiàn)多少次才能滿(mǎn)足匹配。有*或+或?或{n}或{n,}或{n,m}共6種。
          *、+和?限定符都是貪婪的,因?yàn)樗鼈儠?huì)盡可能多的匹配文字,只有在它們的后面加上一個(gè)?就可以實(shí)現(xiàn)非貪婪或最小匹配。
            正則表達(dá)式的限定符有:
            字符 描述
          * 匹配前面的子表達(dá)式零次或多次。例如,zo* 能匹配 “z” 以及 “zoo”。* 等價(jià)于{0,}。
          + 匹配前面的子表達(dá)式一次或多次。例如,’zo+’ 能匹配 “zo” 以及 “zoo”,但不能匹配 “z”。+ 等價(jià)于 {1,}。
          ? 匹配前面的子表達(dá)式零次或一次。例如,”do(es)?” 可以匹配 “do” 或 “does” 中的”do” 。? 等價(jià)于 {0,1}。
          {n} n 是一個(gè)非負(fù)整數(shù)。匹配確定的 n 次。例如,’o{2}’ 不能匹配 “Bob” 中的 ‘o’,但是能匹配 “food” 中的兩個(gè) o。
          {n,} n 是一個(gè)非負(fù)整數(shù)。至少匹配n 次。例如,’o{2,}’ 不能匹配 “Bob” 中的 ‘o’,但能匹配 “foooood” 中的所有 o。’o{1,}’ 等價(jià)于 ‘o+’。’o{0,}’ 則等價(jià)于 ‘o*’。
          {n,m} m 和 n 均為非負(fù)整數(shù),其中n <= m。最少匹配 n 次且最多匹配 m 次。例如,”o{1,3}” 將匹配 “fooooood” 中的前三個(gè) o。’o{0,1}’ 等價(jià)于 ‘o?’。請(qǐng)注意在逗號(hào)和兩個(gè)數(shù)之間不能有空格。

          3.5 定位符
            用來(lái)描述字符串或單詞的邊界,^和$分別指字符串的開(kāi)始與結(jié)束,\b描述單詞的前或后邊界,\B表示非單詞邊界。不能對(duì)定位符使用限定符。

          3.6 選擇
            用圓括號(hào)將所有選擇項(xiàng)括起來(lái),相鄰的選擇項(xiàng)之間用|分隔。但用圓括號(hào)會(huì)有一個(gè)副作用,是相關(guān)的匹配會(huì)被緩存,此時(shí)可用?:放在第一個(gè)選項(xiàng)前來(lái)消除這種副作用。
            其中?:是非捕獲元之一,還有兩個(gè)非捕獲元是?=和?!,這兩個(gè)還有更多的含義,前者為正向預(yù)查,在任何開(kāi)始匹配圓括號(hào)內(nèi)的正則表達(dá)式模式的位置來(lái)匹配搜索字符串,后者為負(fù)向預(yù)查,在任何開(kāi)始不匹配該正則表達(dá)式模式的位置來(lái)匹配搜索字符串。

          3.7 后向引用
            對(duì)一個(gè)正則表達(dá)式模式或部分模式兩邊添加圓括號(hào)將導(dǎo)致相關(guān)匹配存儲(chǔ)到一個(gè)臨時(shí)緩沖區(qū)中,所捕獲的每個(gè)子匹配都按照在正則表達(dá)式模式中從左至右所遇到的內(nèi)容存儲(chǔ)。存儲(chǔ)子匹配的緩沖區(qū)編號(hào)從 1 開(kāi)始,連續(xù)編號(hào)直至最大 99 個(gè)子表達(dá)式。每個(gè)緩沖區(qū)都可以使用 ‘\n’ 訪(fǎng)問(wèn),其中 n 為一個(gè)標(biāo)識(shí)特定緩沖區(qū)的一位或兩位十進(jìn)制數(shù)。
            可以使用非捕獲元字符 ‘?:’, ‘?=’, or ‘?!’ 來(lái)忽略對(duì)相關(guān)匹配的保存。

          4. 各種操作符的運(yùn)算優(yōu)先級(jí)
            相同優(yōu)先級(jí)的從左到右進(jìn)行運(yùn)算,不同優(yōu)先級(jí)的運(yùn)算先高后低。各種操作符的優(yōu)先級(jí)從高到低如下:
            操作符 描述
          \ 轉(zhuǎn)義符
          (), (?:), (?=), [] 圓括號(hào)和方括號(hào)
          *, +, ?, {n}, {n,}, {n,m} 限定符
          ^, $, \anymetacharacter 位置和順序
          | “或”操作

          5. 全部符號(hào)解釋

          字符 描述
          \ 將下一個(gè)字符標(biāo)記為一個(gè)特殊字符、或一個(gè)原義字符、或一個(gè) 向后引用、或一個(gè)八進(jìn)制轉(zhuǎn)義符。例如,’n’ 匹配字符 “n”。’\n’ 匹配一個(gè)換行符。序列 ‘\\’ 匹配 “\” 而 “\(” 則匹配 “(”。
          ^ 匹配輸入字符串的開(kāi)始位置。如果設(shè)置了 RegExp 對(duì)象的 Multiline 屬性,^ 也匹配 ‘\n’ 或 ‘\r’ 之后的位置。
          $ 匹配輸入字符串的結(jié)束位置。如果設(shè)置了RegExp 對(duì)象的 Multiline 屬性,$ 也匹配 ‘\n’ 或 ‘\r’ 之前的位置。
          * 匹配前面的子表達(dá)式零次或多次。例如,zo* 能匹配 “z” 以及 “zoo”。* 等價(jià)于{0,}。
          + 匹配前面的子表達(dá)式一次或多次。例如,’zo+’ 能匹配 “zo” 以及 “zoo”,但不能匹配 “z”。+ 等價(jià)于 {1,}。
          ? 匹配前面的子表達(dá)式零次或一次。例如,”do(es)?” 可以匹配 “do” 或 “does” 中的”do” 。? 等價(jià)于 {0,1}。
          {n} n 是一個(gè)非負(fù)整數(shù)。匹配確定的 n 次。例如,’o{2}’ 不能匹配 “Bob” 中的 ‘o’,但是能匹配 “food” 中的兩個(gè) o。
          {n,} n 是一個(gè)非負(fù)整數(shù)。至少匹配n 次。例如,’o{2,}’ 不能匹配 “Bob” 中的 ‘o’,但能匹配 “foooood” 中的所有 o。’o{1,}’ 等價(jià)于 ‘o+’。’o{0,}’ 則等價(jià)于 ‘o*’。
          {n,m} m 和 n 均為非負(fù)整數(shù),其中n <= m。最少匹配 n 次且最多匹配 m 次。例如,”o{1,3}” 將匹配 “fooooood” 中的前三個(gè) o。’o{0,1}’ 等價(jià)于 ‘o?’。請(qǐng)注意在逗號(hào)和兩個(gè)數(shù)之間不能有空格。
          ? 當(dāng)該字符緊跟在任何一個(gè)其他限制符 (*, +, ?, {n}, {n,}, {n,m}) 后面時(shí),匹配模式是非貪婪的。非貪婪模式盡可能少的匹配所搜索的字符串,而默認(rèn)的貪婪模式則盡可能多的匹配所搜索的字符串。例如,對(duì)于字符串 “oooo”,’o+?’ 將匹配單個(gè) “o”,而 ‘o+’ 將匹配所有 ‘o’。
          . 匹配除 “\n” 之外的任何單個(gè)字符。要匹配包括 ‘\n’ 在內(nèi)的任何字符,請(qǐng)使用象 ‘[.\n]’ 的模式。
          (pattern) 匹配 pattern 并獲取這一匹配。所獲取的匹配可以從產(chǎn)生的 Matches 集合得到,在VBScript 中使用 SubMatches 集合,在JScript 中則使用 $0…$9 屬性。要匹配圓括號(hào)字符,請(qǐng)使用 ‘\(’ 或 ‘\)’。
          (?:pattern) 匹配 pattern 但不獲取匹配結(jié)果,也就是說(shuō)這是一個(gè)非獲取匹配,不進(jìn)行存儲(chǔ)供以后使用。這在使用 “或” 字符 (|) 來(lái)組合一個(gè)模式的各個(gè)部分是很有用。例如, ‘industr(?:y|ies) 就是一個(gè)比 ‘industry|industries’ 更簡(jiǎn)略的表達(dá)式。
          (?=pattern) 正向預(yù)查,在任何匹配 pattern 的字符串開(kāi)始處匹配查找字符串。這是一個(gè)非獲取匹配,也就是說(shuō),該匹配不需要獲取供以后使用。例如,’Windows (?=95|98|NT|2000)’ 能匹配 “Windows 2000″ 中的 “Windows” ,但不能匹配 “Windows 3.1″ 中的 “Windows”。預(yù)查不消耗字符,也就是說(shuō),在一個(gè)匹配發(fā)生后,在最后一次匹配之后立即開(kāi)始下一次匹配的搜索,而不是從包含預(yù)查的字符之后開(kāi)始。
          (?!pattern) 負(fù)向預(yù)查,在任何不匹配 pattern 的字符串開(kāi)始處匹配查找字符串。這是一個(gè)非獲取匹配,也就是說(shuō),該匹配不需要獲取供以后使用。例如’Windows (?!95|98|NT|2000)’ 能匹配 “Windows 3.1″ 中的 “Windows”,但不能匹配 “Windows 2000″ 中的 “Windows”。預(yù)查不消耗字符,也就是說(shuō),在一個(gè)匹配發(fā)生后,在最后一次匹配之后立即開(kāi)始下一次匹配的搜索,而不是從包含預(yù)查的字符之后開(kāi)始
          x|y 匹配 x 或 y。例如,’z|food’ 能匹配 “z” 或 “food”。’(z|f)ood’ 則匹配 “zood” 或 “food”。
          [xyz] 字符集合。匹配所包含的任意一個(gè)字符。例如, ‘[abc]’ 可以匹配 “plain” 中的 ‘a(chǎn)’。
          [^xyz] 負(fù)值字符集合。匹配未包含的任意字符。例如, ‘[^abc]’ 可以匹配 “plain” 中的’p'。
          [a-z] 字符范圍。匹配指定范圍內(nèi)的任意字符。例如,’[a-z]’ 可以匹配 ‘a(chǎn)’ 到 ‘z’ 范圍內(nèi)的任意小寫(xiě)字母字符。
          [^a-z] 負(fù)值字符范圍。匹配任何不在指定范圍內(nèi)的任意字符。例如,’[^a-z]’ 可以匹配任何不在 ‘a(chǎn)’ 到 ‘z’ 范圍內(nèi)的任意字符。
          \b 匹配一個(gè)單詞邊界,也就是指單詞和空格間的位置。例如, ‘er\b’ 可以匹配”never” 中的 ‘er’,但不能匹配 “verb” 中的 ‘er’。
          \B 匹配非單詞邊界。’er\B’ 能匹配 “verb” 中的 ‘er’,但不能匹配 “never” 中的 ‘er’。
          \cx 匹配由 x 指明的控制字符。例如, \cM 匹配一個(gè) Control-M 或回車(chē)符。x 的值必須為 A-Z 或 a-z 之一。否則,將 c 視為一個(gè)原義的 ‘c’ 字符。
          \d 匹配一個(gè)數(shù)字字符。等價(jià)于 [0-9]。
          \D 匹配一個(gè)非數(shù)字字符。等價(jià)于 [^0-9]。
          \f 匹配一個(gè)換頁(yè)符。等價(jià)于 \x0c 和 \cL。
          \n 匹配一個(gè)換行符。等價(jià)于 \x0a 和 \cJ。
          \r 匹配一個(gè)回車(chē)符。等價(jià)于 \x0d 和 \cM。
          \s 匹配任何空白字符,包括空格、制表符、換頁(yè)符等等。等價(jià)于 [ \f\n\r\t\v]。
          \S 匹配任何非空白字符。等價(jià)于 [^ \f\n\r\t\v]。
          \t 匹配一個(gè)制表符。等價(jià)于 \x09 和 \cI。
          \v 匹配一個(gè)垂直制表符。等價(jià)于 \x0b 和 \cK。
          \w 匹配包括下劃線(xiàn)的任何單詞字符。等價(jià)于’[A-Za-z0-9_]’。
          \W 匹配任何非單詞字符。等價(jià)于 ‘[^A-Za-z0-9_]’。
          \xn 匹配 n,其中 n 為十六進(jìn)制轉(zhuǎn)義值。十六進(jìn)制轉(zhuǎn)義值必須為確定的兩個(gè)數(shù)字長(zhǎng)。例如,’\x41′ 匹配 “A”。’\x041′ 則等價(jià)于 ‘\x04′ & “1″。正則表達(dá)式中可以使用 ASCII 編碼。.
          \num 匹配 num,其中 num 是一個(gè)正整數(shù)。對(duì)所獲取的匹配的引用。例如,’(.)\1′ 匹配兩個(gè)連續(xù)的相同字符。
          \n 標(biāo)識(shí)一個(gè)八進(jìn)制轉(zhuǎn)義值或一個(gè)向后引用。如果 \n 之前至少 n 個(gè)獲取的子表達(dá)式,則 n 為向后引用。否則,如果 n 為八進(jìn)制數(shù)字 (0-7),則 n 為一個(gè)八進(jìn)制轉(zhuǎn)義值。
          \nm 標(biāo)識(shí)一個(gè)八進(jìn)制轉(zhuǎn)義值或一個(gè)向后引用。如果 \nm 之前至少有 nm 個(gè)獲得子表達(dá)式,則 nm 為向后引用。如果 \nm 之前至少有 n 個(gè)獲取,則 n 為一個(gè)后跟文字 m 的向后引用。如果前面的條件都不滿(mǎn)足,若 n 和 m 均為八進(jìn)制數(shù)字 (0-7),則 \nm 將匹配八進(jìn)制轉(zhuǎn)義值 nm。
          \nml 如果 n 為八進(jìn)制數(shù)字 (0-3),且 m 和 l 均為八進(jìn)制數(shù)字 (0-7),則匹配八進(jìn)制轉(zhuǎn)義值 nml。
          \un 匹配 n,其中 n 是一個(gè)用四個(gè)十六進(jìn)制數(shù)字表示的 Unicode 字符。例如, \u00A9 匹配版權(quán)符號(hào) (?)。

           

          6. 部分例子

          正則表達(dá)式 說(shuō)明
          /\b([a-z]+) \1\b/gi 一個(gè)單詞連續(xù)出現(xiàn)的位置
          /(\w+):\/\/([^/:]+)(:\d*)?([^# ]*)/ 將一個(gè)URL解析為協(xié)議、域、端口及相對(duì)路徑
          /^(?:Chapter|Section) [1-9][0-9]{0,1}$/ 定位章節(jié)的位置
          /[-a-z]/ A至z共26個(gè)字母再加一個(gè)-號(hào)。
          /ter\b/ 可匹配chapter,而不能terminal
          /\Bapt/ 可匹配chapter,而不能aptitude
          /Windows(?=95 |98 |NT )/ 可匹配Windows95或Windows98或WindowsNT,當(dāng)找到一個(gè)匹配后,從Windows后面開(kāi)始進(jìn)行下一次的檢索匹配。

          7. 正則表達(dá)式匹配規(guī)則
          7.1 基本模式匹配

            一切從最基本的開(kāi)始。模式,是正規(guī)表達(dá)式最基本的元素,它們是一組描述字符串特征的字符。模式可以很簡(jiǎn)單,由普通的字符串組成,也可以非常復(fù)雜,往往用特殊的字符表示一個(gè)范圍內(nèi)的字符、重復(fù)出現(xiàn),或表示上下文。例如:

          ^once

            這個(gè)模式包含一個(gè)特殊的字符^,表示該模式只匹配那些以once開(kāi)頭的字符串。例如該模式與字符串”once upon a time”匹配,與”There once was a man from NewYork”不匹配。正如如^符號(hào)表示開(kāi)頭一樣,$符號(hào)用來(lái)匹配那些以給定模式結(jié)尾的字符串。

          bucket$

            這個(gè)模式與”Who kept all of this cash in a bucket”匹配,與”buckets”不匹配。字符^和$同時(shí)使用時(shí),表示精確匹配(字符串與模式一樣)。例如:

          ^bucket$

            只匹配字符串”bucket”。如果一個(gè)模式不包括^和$,那么它與任何包含該模式的字符串匹配。例如:模式

          once

          與字符串

          There once was a man from NewYork
          Who kept all of his cash in a bucket.

          是匹配的。

            在該模式中的字母(o-n-c-e)是字面的字符,也就是說(shuō),他們表示該字母本身,數(shù)字也是一樣的。其他一些稍微復(fù)雜的字符,如標(biāo)點(diǎn)符號(hào)和白字符(空格、制表符等),要用到轉(zhuǎn)義序列。所有的轉(zhuǎn)義序列都用反斜杠(\)打頭。制表符的轉(zhuǎn)義序列是:\t。所以如果我們要檢測(cè)一個(gè)字符串是否以制表符開(kāi)頭,可以用這個(gè)模式:

          ^\t

          類(lèi)似的,用\n表示“新行”,\r表示回車(chē)。其他的特殊符號(hào),可以用在前面加上反斜杠,如反斜杠本身用\\表示,句號(hào).用\.表示,以此類(lèi)推。

          7.2 字符簇

          在INTERNET的程序中,正規(guī)表達(dá)式通常用來(lái)驗(yàn)證用戶(hù)的輸入。當(dāng)用戶(hù)提交一個(gè)form以后,要判斷輸入的電話(huà)號(hào)碼、地址、EMAIL地址、信用卡號(hào)碼等是否有效,用普通的基于字面的字符是不夠的。

          所以要用一種更自由的描述我們要的模式的辦法,它就是字符簇。要建立一個(gè)表示所有元音字符的字符簇,就把所有的元音字符放在一個(gè)方括號(hào)里:

          [AaEeIiOoUu]

          這個(gè)模式與任何元音字符匹配,但只能表示一個(gè)字符。用連字號(hào)可以表示一個(gè)字符的范圍,如:

          [a-z] //匹配所有的小寫(xiě)字母
          [A-Z] //匹配所有的大寫(xiě)字母
          [a-zA-Z] //匹配所有的字母
          [0-9] //匹配所有的數(shù)字
          [0-9\.\-] //匹配所有的數(shù)字,句號(hào)和減號(hào)
          [ \f\r\t\n] //匹配所有的白字符

          同樣的,這些也只表示一個(gè)字符,這是一個(gè)非常重要的。如果要匹配一個(gè)由一個(gè)小寫(xiě)字母和一位數(shù)字組成的字符串,比如”z2″、”t6″或”g7″,但不是”ab2″、”r2d3″ 或”b52″的話(huà),用這個(gè)模式:

          ^[a-z][0-9]$

          盡管[a-z]代表26個(gè)字母的范圍,但在這里它只能與第一個(gè)字符是小寫(xiě)字母的字符串匹配。

          前面曾經(jīng)提到^表示字符串的開(kāi)頭,但它還有另外一個(gè)含義。當(dāng)在一組方括號(hào)里使用^是,它表示“非”或“排除”的意思,常常用來(lái)剔除某個(gè)字符。還用前面的例子,我們要求第一個(gè)字符不能是數(shù)字:

          ^[^0-9][0-9]$

          這個(gè)模式與”&5″、”g7″及”-2″是匹配的,但與”12″、”66″是不匹配的。下面是幾個(gè)排除特定字符的例子:

          [^a-z] //除了小寫(xiě)字母以外的所有字符
          [^\\\/\^] //除了(\)(/)(^)之外的所有字符
          [^\"\'] //除了雙引號(hào)(")和單引號(hào)(')之外的所有字符

          特殊字符”.” (點(diǎn),句號(hào))在正規(guī)表達(dá)式中用來(lái)表示除了“新行”之外的所有字符。所以模式”^.5$”與任何兩個(gè)字符的、以數(shù)字5結(jié)尾和以其他非“新行”字符開(kāi)頭的字符串匹配。模式”.”可以匹配任何字符串,除了空串和只包括一個(gè)“新行”的字符串。

          PHP的正規(guī)表達(dá)式有一些內(nèi)置的通用字符簇,列表如下:

          字符簇 含義
          [[:alpha:]] 任何字母
          [[:digit:]] 任何數(shù)字
          [[:alnum:]] 任何字母和數(shù)字
          [[:space:]] 任何白字符
          [[:upper:]] 任何大寫(xiě)字母
          [[:lower:]] 任何小寫(xiě)字母
          [[:punct:]] 任何標(biāo)點(diǎn)符號(hào)
          [[:xdigit:]] 任何16進(jìn)制的數(shù)字,相當(dāng)于[0-9a-fA-F]

          7.3 確定重復(fù)出現(xiàn)

          到現(xiàn)在為止,你已經(jīng)知道如何去匹配一個(gè)字母或數(shù)字,但更多的情況下,可能要匹配一個(gè)單詞或一組數(shù)字。一個(gè)單詞有若干個(gè)字母組成,一組數(shù)字有若干個(gè)單數(shù)組成。跟在字符或字符簇后面的花括號(hào)({})用來(lái)確定前面的內(nèi)容的重復(fù)出現(xiàn)的次數(shù)。

          字符簇 含義
          ^[a-zA-Z_]$ 所有的字母和下劃線(xiàn)
          ^[[:alpha:]]{3}$ 所有的3個(gè)字母的單詞
          ^a$ 字母a
          ^a{4}$ aaaa
          ^a{2,4}$ aa,aaa或aaaa
          ^a{1,3}$ a,aa或aaa
          ^a{2,}$ 包含多于兩個(gè)a的字符串
          ^a{2,} 如:aardvark和aaab,但apple不行
          a{2,} 如:baad和aaa,但Nantucket不行
          \t{2} 兩個(gè)制表符
          .{2} 所有的兩個(gè)字符

          這些例子描述了花括號(hào)的三種不同的用法。一個(gè)數(shù)字,{x}的意思是“前面的字符或字符簇只出現(xiàn)x次”;一個(gè)數(shù)字加逗號(hào),{x,}的意思是“前面的內(nèi)容出現(xiàn)x或更多的次數(shù)”;兩個(gè)用逗號(hào)分隔的數(shù)字,{x,y}表示“前面的內(nèi)容至少出現(xiàn)x次,但不超過(guò)y次”。我們可以把模式擴(kuò)展到更多的單詞或數(shù)字:

          ^[a-zA-Z0-9_]{1,}$ //所有包含一個(gè)以上的字母、數(shù)字或下劃線(xiàn)的字符串
          ^[0-9]{1,}$ //所有的正數(shù)
          ^\-{0,1}[0-9]{1,}$ //所有的整數(shù)
          ^\-{0,1}[0-9]{0,}\.{0,1}[0-9]{0,}$ //所有的小數(shù)

          最后一個(gè)例子不太好理解,是嗎?這么看吧:與所有以一個(gè)可選的負(fù)號(hào)(\-{0,1})開(kāi)頭(^)、跟著0個(gè)或更多的數(shù)字([0-9]{0,})、和一個(gè)可選的小數(shù)點(diǎn)(\.{0,1})再跟上0個(gè)或多個(gè)數(shù)字([0-9]{0,}),并且沒(méi)有其他任何東西($)。下面你將知道能夠使用的更為簡(jiǎn)單的方法。

          特殊字符”?”與{0,1}是相等的,它們都代表著:“0個(gè)或1個(gè)前面的內(nèi)容”或“前面的內(nèi)容是可選的”。所以剛才的例子可以簡(jiǎn)化為:

          ^\-?[0-9]{0,}\.?[0-9]{0,}$

          特殊字符”*”與{0,}是相等的,它們都代表著“0個(gè)或多個(gè)前面的內(nèi)容”。最后,字符”+”與 {1,}是相等的,表示“1個(gè)或多個(gè)前面的內(nèi)容”,所以上面的4個(gè)例子可以寫(xiě)成:

          ^[a-zA-Z0-9_]+$ //所有包含一個(gè)以上的字母、數(shù)字或下劃線(xiàn)的字符串
          ^[0-9]+$ //所有的正數(shù)
          ^\-?[0-9]+$ //所有的整數(shù)
          ^\-?[0-9]*\.?[0-9]*$ //所有的小數(shù)

          當(dāng)然這并不能從技術(shù)上降低正規(guī)表達(dá)式的復(fù)雜性,但可以使它們更容易閱讀。

          posted @ 2006-10-14 21:59 xyang 閱讀(372) | 評(píng)論 (0)編輯 收藏

          • Liferay - Liferay is designed to deploy portlets that adhere to the Portlet API (JSR 168). Many useful portlets are bundled with the portal (Mail, Document Library, Calendar, Message Boards, to name a few) and can be used as examples for adding your own custom portlets.
          • Exo - The eXo platform is a powerful Open Source - JSR 168 compliant - enterprise portal built from several modules. Based on the most innovative tools, API and frameworks such as Java Server Faces, Pico Container, JbossMX and AspectJ.
          • Pluto - Pluto is the Reference Implementation of the Java Portlet Specfication. The current version of this specification is JSR 168.
          • JA-SIG uPortal - uPortal is a free, sharable portal under development by institutions of higher-education. Community tools, such as chat, forums, survey, and so on, build relationships among campus constituencies. uPortal is an open-standard effort using Java, XML, JSP and J2EE.
          • Redhat Portal Server - Red Hat Portal Server is a open source Portal solution. Supports multiple languages in its user interface and pervasive devices such as WAP, XHTML, and VoiceXML in its rendering pipeline. Portals can be built and targeted for the individual, for work groups or teams, for people with a common set of interests, and for large corporations and organizations.
          • Jakarta Jetspeed 2 Enterprise Portal - Jetspeed is an Open Source implementation of an Enterprise Information Portal, using Java and XML. etspeed-2 is the next-generation enterprise portal at Apache. Jetspeed-2 offers several architectural enhancements and improvements over Jetspeed 1.0. First, Jetspeed-2 is conformant to the Java Portlet Standard and will provide a standard mechanism for the deployment of portlets.
          • Jahia - An integrated web content management and corporate portal server; 100% Java based; Available under a collaborative source license (contribue or pay paradigm); Installed in minutes; Easy to use and to administer; Full Multilanguage and I18N support; Staging environement; Content Workflow; Content Versioning; Document Management (WebDAV Support); Built-in Portlet-based interface; Built-in support for standardized java web applications and web services (default servlets supported as portlets); Full web-based administration; Integrated with the Apache Lucene Search Engine; LDAP compliant; JSP and JSTL support for easy templates development; Integrated HTML cache engine; dynamic XML export module and much more...
          • Gluecode Portal Foundation Server - Gluecode PFS is built in collaboration with the largest open source communities, including JBoss and Apache. It adheres to J2EE specifications, as well as implementations of portal industry standards.
          • jPortlet - jPortlet is not JSR 168 compliant, but the jPortlet API is very similar to the IBM WebSpere Portal Server.
          • GridSphere - 100% JSR 168 Portlet API compliant. Portlet API implementation nearly fully compatible with IBM's WebSphere 4.2. Higher-level model for building complex portlets using visual beans and the GridSphere User Interface (UI) tag library. Built-in support for Role Based Access Control (RBAC) separating users into guests, users, admins and super users. Persistence of data provided using Hibernate for RDBMS database support Integrated Junit/Cactus unit tests. Localization support including English, French, German, Czech, Polish, Hungarian and Italian.
          • Cocoon Portal Framework - Apache Cocoon is a web development framework built around the concepts of separation of concerns and component-based web development. Cocoon implements these concepts around the notion of 'component pipelines', each component on the pipeline specializing on a particular operation. The Portal Framework is based on Cocoon and is rumored to eventually support JSR-168.
          • jPorta - jPorta is a fully functional portal engine built on top of the Jeenius Framework (http://jeenius.sourceforge.net). It works with any 2.3 compilant servlet engine and comes with a number of useful gadgets.
          • MyPersonalizer - MyPersonalizer is a J2EE-based framework. The controller layer is built upon Jakarta Struts. MyPersonalizer also provides a number of command line administration tools for initialization tasks and a web administration tool to administrate any portal built with the framework.
          • oPortal - The OWASP Portal project, oPortal, is a portal written in java that aims to become the standard for secure web applications. The OWASP portal is based on the Jakarta Struts framework and designed with security as a REQUIREMENT, not an option. A reference implementation of a secure portal, that will rival the likes of any commercially available portal. JSR-168 compliance scheduled for version 1.1 release.
          • CHEF - CompreHensive collaborativeE Framework. CHEF is a Java J2EE (Servlet) based application server. The portal engine is a version of Apache's Jetspeed. CHEF is a set of tools and services. Tools control an application's user interface. Services provide information modeling, persistence, and important application logic. The tools are a set of groupware applications (such as chat, schedule and resources). The services specifically support the tools (such as content hosting and messaging) and generally support the application environment (such as authentication, event tracking, security).
          • Siemens Intranet Portal Framework - The Siemens Intranet Portal Framework (SIPF) offers a personalized, structured access to information and seamless integration of applications. A web-based work environment is realized within a browser by hierarchically structured virtual desktops.
          • Lutece - Lutece is a web portal engine that lets you quickly create internet or intranet dynamic sites based on HTML, XML or database contents. This tool, developed by the Data Processing Department of the City of Paris for the districts web sites projects, is now used by more than 18 web sites of the city.
          • Sakai Project - Builds on JSR 168 and OKI open service interface definitions. A re-factored set of educational software tools that blends the best of features from the University of Michigan, Indiana University, MIT, Stanford, and the uPortal consortium. The Sakai Project will include an Enterprise Services-based Portal, a complete Course Management System with sophisticated assessment tools, a Research Support Collaboration System, a Workflow Engine, and a Technology Portability Profile as a clear standard for writing future tools that can extend this core set of educational applications. The Sakai Project Core universities are committing over $2 million per year to launch and support this two year project.
          • JBoss Portal - JBoss Portal 2.0 framework and architecture includes the portal container and supports a wide range of features including standard portlets, single sign-on, clustering and internationalization. Portal themes and layouts are configurable. Fine-grained security administration down to portlet permissions rounds out the security model. JBoss Portal 2.0 includes a rich content management system and message board support.
          • Stringbeans - Stringbeans is a platform for building enterprise information portals. The platform is composed of three components: a portal container/server, a Web Services framework, and a process automation engine. Compatible with JSR 168 standard, mobile client support (WML 1.1 and XHTML MP 1.0), JAAS-based user authentication, portlets capable of displaying RSS headlines, multi-page tabular data from database tables, reports, charts, XML documents via XSL tranformations. Stringbeans is deployed as a J2EE Web application in a container that supports Servlets 2.3 and Java Server Pages (JSP) 1.2 specification. EJB support is not required.
          • InfoGlue 2.0 - InfoGlue is a GPL-based content management and JSR 168 Portal system. Key features includes full multi-language support, excellent information reuse between sites and extensive integration capabilities. A dynamic visual page builder. This release supports advanced workflows as well as very detailed access control both internally and externally.
          • NodeVision Portal - NVPortal is the Java Enterprise JSR 168 compliant Portal solution based on a BSD-License. Features include a Business Process Engine and Search Engine based on SOAP, WSRP compliance, Multilingual, Single Sign On and a Graphical administration interface.
          • Pentaho - The Pentaho BI Project provides enterprise-class reporting, analysis, dashboard, data mining and workflow capabilities that help organizations operate more efficiently and effectively. The software offers flexible deployment options that enable use as embeddable components, customized BI application solutions, and as a complete out-of-the-box, integrated BI platform.
          • IPoint Open Edition - iPoint Open Edition has passed the JSR168 TCK. It is designed so that the portal can be developed within a browser. iPoint portal contains many prebuilt portlets and features complete browser based management and site construction.
          • Portals in Cocoon - The portal framework is a portal server that runs inside Cocoon - or to be more precise inside the Cocoon servlet. It contains a portlet container that is called coplet container. Coplet stands for Cocoon Portlet and is the Cocoon equivalent to portlet. The new portal engine is a replacement implementation of a portal engine which focuses on more flexibility and ease-of-use. In addition it supports the JSR-168.
          • Enterprise-class Portal Server Open Source project - The Portal Server open source project is derived from the Sun Java System Portal Server 7 product and will comprise of the following components and technologies: Portlet repository, JSR168 compliant portlet container, Web Services for Remote Portlets (WSRP) 1.0 based producer and consumer implementations, Portal aggregation and administration framework, Communities and collaboration framework/services, Full-text search engine with federated search and taxonomy capabilities, Secure remote access for SSL/VPN capabilities from outside the firewall and Multi-device mobile access capability to all portal content and applications.

          posted @ 2006-10-10 09:44 xyang 閱讀(667) | 評(píng)論 (0)編輯 收藏

          1.?自動(dòng)裝箱與拆箱?對(duì)應(yīng)C#
          ?例1.1
          ??Integer?i?=?10;
          ??int?j?=?i;
          ??
          2.?更優(yōu)化的for循環(huán)?對(duì)應(yīng)就C#---foreach循環(huán)
          ?例2.1
          ??String[]?names?=?{"BadBoy","GoodBoy","HappyGirl","sadGirl"};
          ??for(String?option:?names)?{
          ???System.out.println(option);
          ??}
          ?例2.2?加泛型?對(duì)應(yīng)C++模板
          ??import?java.util.*;
          ??
          ??ArrayList<String>?animals?=?new?ArrayList<String>();
          ??animals.add("Dog");
          ??animals.add("Cat");
          ??animals.add("Chick");
          ??animals.add("Cow");
          ??for(String?option?:?animals)?{
          ???System.out.println(option);
          ??}
          ??
          3.參數(shù)可變的方法和printf
          ?例3.1
          ??定義:
          ??public?int?sum(int...?n)?{??//傳過(guò)來(lái)n為一個(gè)int型數(shù)組
          ???int?tempSum;
          ???for(int?option?:?n)?{
          ????tempSum+=option;
          ???}
          ???/*
          ???for(int?i?=?0;?i?<?n.length;?i++)?{
          ????tempSum+=n[i];
          ???}
          ???*/
          ???return?tempSum;
          ??}
          ??調(diào)用1:?sum(1);
          ??調(diào)用2:?sum(1,2);
          ??調(diào)用3:?sum(1,2,3,4);
          ?例3.2?printf方法,??對(duì)應(yīng)c語(yǔ)言的printf
          ??int?x?=?10;
          ??int?y?=?20;
          ??int?sum?=?x?+?y;
          ??System.out.printf("%d?+?%d?=?%d",x,y,sum);
          4.?枚舉
          ?例4.1
          ??public?enum?MyColors?{
          ???red,
          ???black,
          ???blue,
          ???green,
          ???yellow
          ??}
          ??
          ??MyColors?color?=?MyColors.red;
          ??for(MyColors?option?:?color.values())?{
          ???System.out.println(option);
          ??}

          /**不能在switch語(yǔ)句里這樣寫(xiě)case?MyColors.red:
          ?*這樣編譯器不會(huì)讓你通過(guò)*/
          switch(color)?{
          ?case?red:
          ??System.out.println("best?color?is?"+red);
          ??break;
          ?case?black:
          ??System.out.println("NO?"?+?black);
          ??break;
          ?default:
          ??System.out.println("What");
          ??break;
          }

          5.靜態(tài)引用
          ?例5.1
          ??1.5版本以前的寫(xiě)法是:
          ?
          ??  import?java.lang.Math;?//程序開(kāi)頭處
          ??
          ??  ...
          ??
          ??  double?x?=?Math.random();?
          ??1.5版本中可以這樣寫(xiě)
          ???import?static?java.lang.Math.random;?//程序開(kāi)頭處
          ???
          ???...
          ??  
          ???double?x?=?random();??

          posted @ 2006-10-09 23:05 xyang 閱讀(275) | 評(píng)論 (0)編輯 收藏

          這個(gè)題目含有許多需要解釋的概念,最容易說(shuō)明的是“站內(nèi)消息”,這是很多論壇都有的功能,可以通過(guò)web向其他的在線(xiàn)用戶(hù)發(fā)送消息,很多用戶(hù)都使用過(guò)。站內(nèi)消息的第一個(gè)好處是大家都不需要安裝客戶(hù)端,你不用知道對(duì)方的MSN或者QQ,就能與他聯(lián)系,稱(chēng)贊他的觀(guān)點(diǎn)或者是給他一頓臭罵。第二個(gè)好處是客戶(hù)管理方便,利用session來(lái)維護(hù)在線(xiàn)名單,各種腳本都已經(jīng)把session操作封裝得很易用了,不用像其他無(wú)狀態(tài)的即時(shí)通信工具(比如使用UDP通信的工具)一樣,要費(fèi)一些腦細(xì)胞來(lái)解決在線(xiàn)名單的問(wèn)題。缺點(diǎn)嘛,就是實(shí)時(shí)性不好,一般是在用戶(hù)跳轉(zhuǎn)或者刷新頁(yè)面才能探測(cè)消息、更新在線(xiàn)名單。

            Session監(jiān)聽(tīng)嘛,沒(méi)什么好解釋的,java提供了很靈活的事件機(jī)制來(lái)監(jiān)聽(tīng)session,可以監(jiān)聽(tīng)session的創(chuàng)建和銷(xiāo)毀,監(jiān)控session所攜帶數(shù)據(jù)的創(chuàng)建、變化和銷(xiāo)毀,可以監(jiān)聽(tīng)session的銳化和鈍化(了解對(duì)象序列化的兄弟應(yīng)該知道這個(gè)),其他的平臺(tái)是個(gè)什么情況我不太清楚,估計(jì)也差不多吧。如果能夠?qū)λ锌蛻?hù)的session進(jìn)行監(jiān)控,就不用再去操作麻煩而危險(xiǎn)的Application了。

            Xmlhttp是MS推的一項(xiàng)技術(shù),功能很復(fù)雜,可以做很多事情,比如客戶(hù)端可以在簡(jiǎn)單的HTML中打開(kāi)HTTP連接,主動(dòng)向server請(qǐng)求數(shù)據(jù)并獲得返回?cái)?shù)據(jù),是DOM技術(shù)一個(gè)非常重要的應(yīng)用,利用它來(lái)寫(xiě)無(wú)刷新的動(dòng)態(tài)頁(yè)面簡(jiǎn)直是so?easy,做過(guò)web開(kāi)發(fā)的兄弟應(yīng)該明白它的意義有多么重大。

          一、?session監(jiān)聽(tīng)

            servlet中對(duì)session的監(jiān)聽(tīng)有很多接口,功能很靈活,最常用的是監(jiān)聽(tīng)Session和Attribute。這里要澄清一下概念,servlet中的session監(jiān)聽(tīng)和Attribute監(jiān)聽(tīng)含義有差別,session監(jiān)聽(tīng)指的不是我們一般所理解的放置一個(gè)session或者銷(xiāo)毀一個(gè)session,這是Attribute監(jiān)聽(tīng)的功能,因?yàn)閟ervlet中放置session的語(yǔ)法是session.setAttribute(“session名”,要放入的對(duì)象)。而session監(jiān)聽(tīng),監(jiān)聽(tīng)的是HTTP連接,只要有用戶(hù)與server連接,就算連接的是一個(gè)空白的jsp頁(yè)面,也會(huì)觸發(fā)session事件,所以此處的session實(shí)際上指的是connection,用來(lái)統(tǒng)計(jì)當(dāng)前在線(xiàn)用戶(hù)數(shù)最合適了。不知道我說(shuō)清楚了沒(méi)有。下面分別講解這兩種監(jiān)聽(tīng)方式。

          1、?session監(jiān)聽(tīng)

            首先編寫(xiě)一個(gè)session監(jiān)聽(tīng)類(lèi),實(shí)作HttpSessionListener接口,它的作用是計(jì)算當(dāng)前有多少個(gè)在線(xiàn)用戶(hù):

          1. /**
          2. *@Author?bromon
          3. *2004-6-12
          4. */
          5. package?org.bromon.test;
          6. import?javax.servlet.*;
          7. import?javax.servlet.http.*;
          8. public?class?SessionCount?implements?HttpSessionListener
          9. {
          10. ????private?static?int?count=0;
          11. ????public?void?sessionCreated(HttpSessionEvent?se)
          12. ????{
          13. ????????count++;
          14. ????????System.out.println(“session創(chuàng)建:”+new?java.util.Date());
          15. ????}
          16. ????public?void?sessionDestroyed(HttpSessionEvent?se)
          17. ????{
          18. ???????count--;
          19. ???????System.out.println(“session銷(xiāo)毀:”+new?java.util.Date());
          20. ????}
          21. ????public?static?int?getCount()
          22. ????{
          23. ???????return(count);
          24. ?????}
          25. }



            怎么樣,是不是一目了然?count被定義為static,是因?yàn)橐WC整個(gè)系統(tǒng)只有這一個(gè)count。如果你實(shí)在不放心,可以把它寫(xiě)成一個(gè)單例類(lèi)。

            然后在web.xml中聲明這個(gè)監(jiān)聽(tīng)器:
          <listener>
          <listener-class>
          org.bromon.test.SessionCount
          </listener-class>
          </listener>

            編寫(xiě)一個(gè)測(cè)試頁(yè)面test.jsp,內(nèi)容是獲得count:
          <%
          int?count=org.bromon.test.SessionCount.getCount();
          out.println(count);
          %>

            需要注意的是,這里根本不涉及任何session的操作。重啟動(dòng)App?server,試著連接test.jsp,可以看到監(jiān)聽(tīng)器已經(jīng)開(kāi)始工作。

          2、?Attribute監(jiān)聽(tīng)
            作為一個(gè)站內(nèi)消息系統(tǒng),肯定要獲得所有登陸者的ID,才有可能互發(fā)消息。這就涉及Attribute監(jiān)聽(tīng)。假設(shè)我們寫(xiě)了個(gè)用戶(hù)登陸的模塊,用戶(hù)通過(guò)身份驗(yàn)證之后會(huì)產(chǎn)生一個(gè)session,保存它的相關(guān)信息,比如:
          1. //check.jsp
          2. <%
          3. ????String?name=request.getParameter(“name”);
          4. ????Name=new?String(name.getBytes(“ISO8859-1”));
          5. ????session.setAttribute(“user”,name);
          6. %>


            做過(guò)jsp的兄弟應(yīng)該對(duì)這段代碼再熟悉不過(guò)了,下面寫(xiě)個(gè)監(jiān)聽(tīng)器來(lái)監(jiān)聽(tīng)用戶(hù)登陸,把所有用戶(hù)的ID保存到一個(gè)List當(dāng)中,這個(gè)監(jiān)聽(tīng)器實(shí)作HttpSessionAttributeListener接口:

          1. /**
          2. *@Author?bromon
          3. *2004-6-12
          4. */
          5. package?org.bromon.test;
          6. import?javax.servlet.*;
          7. import?javax.servlet.http.*;
          8. import?java.util.*;
          9. public?class?OnlineList?implements?HttpSessionAttributeListener
          10. {
          11. ????private?static?List?list=new?ArrayList();
          12. ????public?void?attributeAdded(HttpSessionBindingEvent?se)
          13. ????{
          14. ????????if(“user”.equals(se.getName()))
          15. ????????{
          16. ????????????list.add(se.getValue());
          17. ?????????}
          18. ????}
          19. ????public?void?attributeRemoved(HttpSessionBindingEvent?se)
          20. ????{
          21. ?????????if(“user”.equals(se.getName()))
          22. ?????????{
          23. ????????????list.remove(se.getValue());
          24. ?????????}
          25. ????}
          26. ????public?void?attributeReplaced(HttpSessionBindingEvent?se){}
          27. ????public?static?List?getList()
          28. ????{
          29. ?????????return(list);
          30. ?????}
          31. }


          寫(xiě)個(gè)簡(jiǎn)單的jsp來(lái)得到用戶(hù)列表:
          <%
          ????java.util.List?list=org.bromon.test.OnlineList.getList();
          ????out.println(“共有”+list.size()+”名用戶(hù)已登陸:”);
          ????for(int?I=0;I<lise.size();i++)
          ????{
          ????????out.println(list.get(i));
          ????}
          %>

          也許你說(shuō),這有什么神奇呢,監(jiān)聽(tīng)session而已,不著急,看看xmlhttp。

          二、?XMLHTTP

            XMLHTTP的用處很多,這里只說(shuō)我們需要的,就是無(wú)刷新的與server通信,看這段代碼:

          1. <script?language="javascript">?
          2. xml?=?new?ActiveXObject("Microsoft.XMLHTTP");?
          3. var?post="?";//構(gòu)造要攜帶的數(shù)據(jù)?
          4. xml.open("POST","http://localhost:7001/TestWL/index.jsp",false);//使用POST方法打開(kāi)一個(gè)到服務(wù)器的連接,以異步方式通信?
          5. xml.setrequestheader("content-length",post.length);?
          6. xml.setrequestheader("content-type","application/x-www-form-urlencoded");?
          7. xml.send(post);//發(fā)送數(shù)據(jù)?
          8. var?res?=?xml.responseText;//接收服務(wù)器返回的數(shù)據(jù)?
          9. document.write(res);?
          10. </script>



            豁然開(kāi)朗,這段代碼就是打開(kāi)一個(gè)HTTP連接,以標(biāo)準(zhǔn)的HTTP格式傳遞數(shù)據(jù),如果你喜歡,可以用XML的格式來(lái)傳遞。更改一下xml對(duì)象的構(gòu)造方式就可以兼容Mozilla和Netscape。下面來(lái)寫(xiě)一個(gè)輪詢(xún),每隔一段時(shí)間刷新一次用戶(hù)列表,當(dāng)然,是不需要刷新頁(yè)面的:

          1. <html>
          2. <head><title>探測(cè)器</title>
          3. <script?language="javascript">
          4. function?detect()
          5. {
          6. xml?=?new?ActiveXObject("Microsoft.XMLHTTP");?
          7. var?post="?";//構(gòu)造要攜帶的數(shù)據(jù)?
          8. xml.open("POST","http://localhost:7001/TestWL/index.jsp",false);//使用POST方法打開(kāi)一個(gè)到服務(wù)器的連接,以異步方式通信?
          9. xml.setrequestheader("content-length",post.length);?
          10. xml.setrequestheader("content-type","application/x-www-form-urlencoded");?
          11. xml.send(post);//發(fā)送數(shù)據(jù)?
          12. var?res?=?xml.responseText;//接收服務(wù)器返回的數(shù)據(jù)?
          13. list.innerText=res;
          14. setTimeout(“detect()”,5000);//每隔5秒鐘輪詢(xún)一次
          15. }?
          16. </script>
          17. <body?onload=”detect()”>
          18. <a?id=”list”></a>
          19. </body>
          20. </html>
          21. 這樣的通信方式數(shù)據(jù)量很小,不用重新傳遞整個(gè)頁(yè)面,5秒鐘輪一次,普通PC也能承受較大的在線(xiàn)數(shù)。構(gòu)造一個(gè)探測(cè)器來(lái)監(jiān)聽(tīng)在線(xiàn)列表和消息,效果是很好的,即使你的客戶(hù)坐在電腦前袖手旁觀(guān),鍵鼠都不碰一下,也能保證數(shù)據(jù)即時(shí)傳遞,頁(yè)面也不會(huì)發(fā)生跳轉(zhuǎn)和刷新。

              Session監(jiān)聽(tīng)加上XMLHTTP通信,開(kāi)發(fā)一個(gè)較為完善的站內(nèi)消息系統(tǒng)實(shí)在易如反掌

          posted @ 2006-10-09 22:58 xyang 閱讀(1417) | 評(píng)論 (1)編輯 收藏

          計(jì)算機(jī)常用英語(yǔ)
          計(jì)算機(jī)常用英語(yǔ)術(shù)語(yǔ)、詞匯表
          Computer Vocabulary In Common [color=darkblue][/color]Use
          一、硬件類(lèi)(Hardware)
          二、軟件類(lèi)(Software)
          三、網(wǎng)絡(luò)類(lèi)(Network)
          四、其它

          CPU(Center Processor Unit)中央處理單元
          mainboard主板
          RAM(random access
          memory)隨機(jī)存儲(chǔ)器(內(nèi)存)
          ROM(Read Only Memory)只讀存儲(chǔ)器
          Floppy Disk軟盤(pán)
          Hard Disk硬盤(pán)
          CD-ROM光盤(pán)驅(qū)動(dòng)器(光驅(qū))
          monitor監(jiān)視器
          keyboard鍵盤(pán)
          mouse鼠標(biāo)
          chip芯片
          CD-R光盤(pán)刻錄機(jī)
          HUB集線(xiàn)器
          Modem= MOdulator-DEModulator,調(diào)制解調(diào)器
          P-P(Plug and Play)即插即用
          UPS(Uninterruptable Power Supply)不間斷電源
          BIOS(Basic-input-Output
          System)基本輸入輸出系統(tǒng)
          CMOS(Complementary Metal-Oxide-Semiconductor)互補(bǔ)金屬氧化物半導(dǎo)體
          setup安裝
          uninstall卸載
          wizzard向?qū)?
          OS(Operation Systrem)操作系統(tǒng)
          OA(Office AutoMation)辦公自動(dòng)化
          exit退出
          edit編輯
          copy復(fù)制
          cut剪切
          paste粘貼
          delete刪除
          select選擇
          find查找
          select all全選
          replace替換
          undo撤消
          redo重做
          program程序
          license許可(證)
          back前一步
          next下一步
          finish結(jié)束
          folder文件夾
          Destination Folder目的文件夾
          user用戶(hù)
          click點(diǎn)擊
          double click雙擊
          right click右擊
          settings設(shè)置
          update更新
          release發(fā)布
          data數(shù)據(jù)
          data base數(shù)據(jù)庫(kù)
          DBMS(Data Base Manege
          System)數(shù)據(jù)庫(kù)管理系統(tǒng)
          view視圖
          insert插入
          object對(duì)象
          configuration配置
          command命令
          document文檔
          POST(power-on-self-test)電源自檢程序
          cursor光標(biāo)
          attribute屬性
          icon圖標(biāo)
          service pack服務(wù)補(bǔ)丁
          option pack功能補(bǔ)丁
          Demo演示
          short cut快捷方式
          exception異常
          debug調(diào)試
          previous前一個(gè)
          column行
          row列
          restart重新啟動(dòng)
          text文本
          font字體
          size大小
          scale比例
          interface界面
          function函數(shù)
          access訪(fǎng)問(wèn)
          manual指南
          active激活
          computer language計(jì)算機(jī)語(yǔ)言
          menu菜單
          GUI(graphical user
          interfaces )圖形用戶(hù)界面
          template模版
          page setup頁(yè)面設(shè)置
          password口令
          code密碼
          print preview打印預(yù)覽
          zoom in放大
          zoom out縮小
          pan漫游
          cruise漫游
          full screen全屏
          tool bar工具條
          status bar狀態(tài)條
          ruler標(biāo)尺
          table表
          paragraph段落
          symbol符號(hào)
          style風(fēng)格
          execute執(zhí)行
          graphics圖形
          image圖像
          Unix用于服務(wù)器的一種操作系統(tǒng)
          Mac OS蘋(píng)果公司開(kāi)發(fā)的操作系統(tǒng)
          OO(Object-Oriented)面向?qū)ο?
          virus病毒
          file文件
          open打開(kāi)
          colse關(guān)閉
          new新建
          save保存
          exit退出
          clear清除
          default默認(rèn)
          LAN局域網(wǎng)
          WAN廣域網(wǎng)
          Client/Server客戶(hù)機(jī)/服務(wù)器
          ATM( Asynchronous
          Transfer Mode)異步傳輸模式
          Windows NT微軟公司的網(wǎng)絡(luò)操作系統(tǒng)
          Internet互聯(lián)網(wǎng)
          WWW(World Wide Web)萬(wàn)維網(wǎng)
          protocol協(xié)議
          HTTP超文本傳輸協(xié)議
          FTP文件傳輸協(xié)議
          Browser瀏覽器
          homepage主頁(yè)
          Webpage網(wǎng)頁(yè)
          website網(wǎng)站
          URL在Internet的WWW服務(wù)程序上
          用于指定信息位置的表示方法
          Online在線(xiàn)
          Email電子郵件
          ICQ網(wǎng)上尋呼
          Firewall防火墻
          Gateway網(wǎng)關(guān)
          HTML超文本標(biāo)識(shí)語(yǔ)言
          hypertext超文本
          hyperlink超級(jí)鏈接
          IP(Address)互聯(lián)網(wǎng)協(xié)議(地址)
          SearchEngine搜索引擎
          TCP/IP用于網(wǎng)絡(luò)的一組通訊協(xié)議
          Telnet遠(yuǎn)程登錄
          IE(Internet Explorer)探索者(微軟公司的網(wǎng)絡(luò)瀏覽器)
          Navigator引航者(網(wǎng)景公司的瀏覽器)
          multimedia多媒體
          ISO國(guó)際標(biāo)準(zhǔn)化組織
          ANSI美國(guó)國(guó)家標(biāo)準(zhǔn)協(xié)會(huì)
          able 能
          activefile 活動(dòng)文件
          addwatch 添加監(jiān)視點(diǎn)
          allfiles 所有文件
          allrightsreserved 所有的權(quán)力保留
          altdirlst 切換目錄格式
          andfixamuchwiderrangeofdiskproblems 并能夠解決更大范圍內(nèi)的磁盤(pán)問(wèn)題
          andotherinFORMation 以及其它的信息
          archivefileattribute 歸檔文件屬性
          assignto 指定到
          autoanswer 自動(dòng)應(yīng)答
          autodetect 自動(dòng)檢測(cè)
          autoindent 自動(dòng)縮進(jìn)
          autosave 自動(dòng)存儲(chǔ)
          availableonvolume 該盤(pán)剩余空間
          badcommand 命令錯(cuò)
          badcommandorfilename 命令或文件名錯(cuò)
          batchparameters 批處理參數(shù)
          binaryfile 二進(jìn)制文件
          binaryfiles 二進(jìn)制文件
          borlandinternational borland國(guó)際公司
          bottommargin 頁(yè)下空白
          bydate 按日期
          byextension 按擴(kuò)展名
          byname 按名稱(chēng)
          bytesfree 字節(jié)空閑
          callstack 調(diào)用棧
          casesensitive 區(qū)分大小寫(xiě)
          causespromptingtoconfirmyouwanttooverwritean 要求出現(xiàn)確認(rèn)提示,在你想覆蓋一個(gè)
          centralpointsoftwareinc central point 軟件股份公司
          changedirectory 更換目錄
          changedrive 改變驅(qū)動(dòng)器
          changename 更改名稱(chēng)
          characterset 字符集
          checkingfor 正在檢查
          checksadiskanddisplaysastatusreport 檢查磁盤(pán)并顯示一個(gè)狀態(tài)報(bào)告
          chgdrivepath 改變盤(pán)/路徑
          china 中國(guó)
          chooseoneofthefollowing 從下列中選一項(xiàng)
          clearall 全部清除
          clearallbreakpoints 清除所有斷點(diǎn)
          clearsanattribute 清除屬性
          clearscommandhistory 清除命令歷史
          clearscreen 清除屏幕
          closeall 關(guān)閉所有文件
          codegeneration 代碼生成
          colorpalette 彩色調(diào)色板
          commandline 命令行
          commandprompt 命令提示符
          compressedfile 壓縮文件
          configuresaharddiskforusewithmsdos 配置硬盤(pán),以為 MS-DOS 所用
          conventionalmemory 常規(guī)內(nèi)存
          copiesdirectoriesandsubdirectorie***ceptemptyones 拷貝目錄和子目錄,空的除外
          copiesfileswiththearchiveattributeset 拷貝設(shè)置了歸檔屬性的文件
          copiesoneormorefilestoanotherlocation 把文件拷貝或搬移至另一地方
          copiesthecontentsofonefloppydisktoanother 把一個(gè)軟盤(pán)的內(nèi)容拷貝到另一個(gè)軟盤(pán)上
          copydiskette 復(fù)制磁盤(pán)
          copymovecompfindrenamedeletevervieweditattribwordpprintlist C拷貝M移動(dòng) O比 F搜索R改名 D刪除 V版本 E瀏覽A屬性 W寫(xiě)字 P打印 L列表
          copyrightc 版權(quán)(c
          createdospartitionorlogicaldosdrive 創(chuàng)建DOS分區(qū)或邏輯DOS驅(qū)動(dòng)器
          createextendeddospartition 創(chuàng)建擴(kuò)展DOS分區(qū)
          createlogicaldosdrivesintheextendeddospartition 在擴(kuò)展DOS分區(qū)中創(chuàng)建邏輯DOS驅(qū)動(dòng)器
          createprimarydospartition 創(chuàng)建DOS主分區(qū)
          createsadirectory 創(chuàng)建一個(gè)目錄
          createschangesordeletesthevolumelabelofadisk 創(chuàng)建,改變或刪除磁盤(pán)的卷標(biāo)
          currentfile 當(dāng)前文件
          currentfixeddiskdrive 當(dāng)前硬盤(pán)驅(qū)動(dòng)器
          currentsettings 當(dāng)前設(shè)置
          currenttime 當(dāng)前時(shí)間
          cursorposition 光標(biāo)位置
          defrag 整理碎片
          dele 刪去
          deletepartitionorlogicaldosdrive 刪除分區(qū)或邏輯DOS驅(qū)動(dòng)器
          deletesadirectoryandallthesubdirectoriesandfilesinit 刪除一個(gè)目錄和所有的子目錄及其中的所有文件
          deltree 刪除樹(shù)
          devicedriver 設(shè)備驅(qū)動(dòng)程序
          dialogbox 對(duì)話(huà)欄
          directionkeys 方向鍵
          directly 直接地
          directorylistargument 目錄顯示變量
          directoryof 目錄清單
          directorystructure 目錄結(jié)構(gòu)
          diskaccess 磁盤(pán)存取
          diskcopy 磁盤(pán)拷貝
          diskservicescopycomparefindrenameverifyvieweditmaplocateinitialize 磁盤(pán)服務(wù)功能: C拷貝 O比較 F搜索R改卷名V校驗(yàn) 瀏覽E編緝M圖 L找文件 N格式化
          diskspace 磁盤(pán)空間
          displayfile 顯示文件
          displayoptions 顯示選項(xiàng)
          displaypartitioninFORMation 顯示分區(qū)信息
          displaysfilesinspecifieddirectoryandallsubdirectories 顯示指定目錄和所有目錄下的文件
          displaysfileswithspecifiedattributes 顯示指定屬性的文件
          displaysorchangesfileattributes 顯示或改變文件屬性
          displaysorsetsthedate 顯示或設(shè)備日期
          displayssetupscreensinmonochromeinsteadofcolor 以單色而非彩色顯示安裝屏信息
          displaystheamountofusedandfreememoryinyoursystem 顯示系統(tǒng)中已用和未用的內(nèi)存數(shù)量
          displaysthefullpathandnameofeveryfileonthedisk 顯示磁盤(pán)上所有文件的完整路徑和名稱(chēng)
          displaysthenameoforchangesthecurrentdirectory 顯示或改變當(dāng)前目錄
          doctor 醫(yī)生
          doesn 不
          doesntchangetheattribute 不要改變屬性
          dosshell DOS 外殼
          doubleclick 雙擊
          doyouwanttodisplaythelogicaldriveinFORMationyn 你想顯示邏輯驅(qū)動(dòng)器信息嗎(y/n)?
          driveletter 驅(qū)動(dòng)器名
          editmenu 編輯選單
          emsmemory ems內(nèi)存
          endoffile 文件尾
          endofline 行尾
          enterchoice 輸入選擇
          entiredisk 轉(zhuǎn)換磁盤(pán)
          environmentvariable 環(huán)境變量
          esc esc
          everyfileandsubdirectory 所有的文件和子目錄
          existingdestinationfile 已存在的目錄文件時(shí)
          expandedmemory 擴(kuò)充內(nèi)存
          expandtabs 擴(kuò)充標(biāo)簽
          explicitly 明確地
          extendedmemory 擴(kuò)展內(nèi)存
          fastest 最快的
          fatfilesystem fat 文件系統(tǒng)
          fdiskoptions fdisk選項(xiàng)
          fileattributes 文件屬性
          fileFORMat 文件格式
          filefunctions 文件功能
          fileselection 文件選擇
          fileselectionargument 文件選擇變?cè)?
          filesin 文件在
          filesinsubdir 子目錄中文件
          fileslisted 列出文件
          filespec 文件說(shuō)明
          filespecification 文件標(biāo)識(shí)
          filesselected 選中文件
          findfile 文件查尋
          fixeddisk 硬盤(pán)
          fixeddisksetupprogram 硬盤(pán)安裝程序
          fixeserrorsonthedisk 解決磁盤(pán)錯(cuò)誤
          floppydisk 軟盤(pán)
          FORMatdiskette 格式化磁盤(pán)
          FORMatsadiskforusewithmsdos 格式化用于MS-DOS的磁盤(pán)
          FORMfeed 進(jìn)紙
          freememory 閑置內(nèi)存
          fullscreen 全屏幕
          functionprocedure 函數(shù)過(guò)程
          graphical 圖解的
          graphicslibrary 圖形庫(kù)
          groupdirectoriesfirst 先顯示目錄組
          hangup 掛斷
          harddisk 硬盤(pán)
          hardwaredetection 硬件檢測(cè)
          hasbeen 已經(jīng)
          helpfile 幫助文件
          helpindex 幫助索引
          helpinFORMation 幫助信息
          helppath 幫助路徑
          helpscreen 幫助屏
          helptext 幫助說(shuō)明
          helptopics 幫助主題
          helpwindow 幫助窗口
          hiddenfile 隱含文件
          hiddenfileattribute 隱含文件屬性
          hiddenfiles 隱含文件
          howto 操作方式
          ignorecase 忽略大小寫(xiě)
          inbothconventionalanduppermemory 在常規(guī)和上位內(nèi)存
          incorrectdos 不正確的DOS
          incorrectdosversion DOS 版本不正確
          indicatesabinaryfile 表示是一個(gè)二進(jìn)制文件
          indicatesanasciitextfile 表示是一個(gè)ascii文本文件
          insertmode 插入方式
          insteadofusingchkdsktryusingscandisk 請(qǐng)用scandisk,不要用chkdsk
          inuse 在使用
          invaliddirectory 無(wú)效的目錄
          is 是
          kbytes 千字節(jié)
          keyboardtype 鍵盤(pán)類(lèi)型
          labeldisk 標(biāo)注磁盤(pán)
          laptop 膝上
          largestexecutableprogram 最大可執(zhí)行程序
          largestmemoryblockavailable 最大內(nèi)存塊可用
          lefthanded 左手習(xí)慣
          leftmargin 左邊界
          linenumber 行號(hào)
          linenumbers 行號(hào)
          linespacing 行間距
          listbyfilesinsortedorder 按指定順序顯示文件
          listfile 列表文件
          listof 清單
          locatefile 文件定位
          lookat 查看
          lookup 查找
          macroname 宏名字
          makedirectory 創(chuàng)建目錄
          memoryinfo 內(nèi)存信息
          memorymodel 內(nèi)存模式
          menubar 菜單條
          menucommand 菜單命令
          menus 菜單
          messagewindow 信息窗口
          microsoft 微軟
          microsoftantivirus 微軟反病毒軟件
          microsoftcorporation 微軟公司
          mini 小的
          modemsetup 調(diào)制解調(diào)器安裝
          modulename 模塊名
          monitor mode 監(jiān)控狀態(tài)
          monochromemonitor 單色監(jiān)視器
          move to 移至
          multi 多
          newdata 新建數(shù)據(jù)
          newer 更新的
          newfile 新文件
          newname 新名稱(chēng)
          newwindow 新建窗口
          norton norton
          nostack 棧未定義
          noteusedeltreecautiously 注意:小心使用deltree
          onlinehelp 聯(lián)機(jī)求助
          optionally 可選擇地
          or 或
          pageframe 頁(yè)面
          pagelength 頁(yè)長(zhǎng)
          pausesaftereachscreenfulofinFORMation 在顯示每屏信息后暫停一下
          pctools pc工具
          postscript 附言
          prefixmeaningnot 前綴意即\"不
          prefixtoreverseorder 反向顯示的前綴
          presetswitchesbyprefixinganyswitchwithhyphenforexamplew 用前綴和放在短橫線(xiàn)-后的開(kāi)關(guān)(例如/-w)預(yù)置開(kāi)關(guān)
          pressakeytoresume 按一鍵繼續(xù)
          pressanykeyforfilefunctions 敲任意鍵執(zhí)行文件功能
          pressentertokeepthesamedate 敲回車(chē)以保持相同的日期
          pressentertokeepthesametime 敲回車(chē)以保持相同的時(shí)間
          pressesctocontinue 敲esc繼續(xù)
          pressesctoexit 敲<esc>鍵退出
          pressesctoexitfdisk 敲esc退出fdisk
          pressesctoreturntofdiskoptions 敲esc返回fdisk選項(xiàng)
          previously 在以前
          printall 全部打印
          printdevice 打印設(shè)備
          printerport 打印機(jī)端口
          processesfilesinalldirectoriesinthespecifiedpath 在指定的路徑下處理所有目錄下的文件
          programfile 程序文件
          programmingenvironment 程序設(shè)計(jì)環(huán)境
          promptsyoubeforecreatingeachdestinationfile 在創(chuàng)建每個(gè)目標(biāo)文件時(shí)提醒你
          promptsyoutopressakeybeforecopying 在拷貝前提示你敲一下鍵
          pulldown 下拉
          pulldownmenus 下拉式選單
          quickFORMat 快速格式化
          quickview 快速查看
          readonlyfile 只讀文件
          readonlyfileattribute 只讀文件屬性
          readonlyfiles 只讀文件
          readonlymode 只讀方式
          redial 重?fù)?
          repeatlastfind 重復(fù)上次查找
          reportfile 報(bào)表文件
          resize 調(diào)整大小
          respectively 分別地
          rightmargin 右邊距
          rootdirectory 根目錄
          runsdebugaprogramtestingandeditingtool 運(yùn)行debug, 它是一個(gè)測(cè)試和編輯工具
          runtimeerror 運(yùn)行時(shí)出錯(cuò)
          save all 全部保存
          save as 另存為
          scandisk 磁盤(pán)掃描程序
          scandiskcanreliablydetect scandisk可以可靠地發(fā)現(xiàn)
          screencolors 屏幕色彩
          screenoptions 屏幕任選項(xiàng)
          screensaver 屏幕暫存器
          screensavers 屏幕保護(hù)程序
          screensize 屏幕大小
          scrollbars 翻卷欄
          scrolllockoff 滾屏已鎖定
          searchfor 搜索
          sectorspertrack 每道扇區(qū)數(shù)
          selectgroup 選定組
          selectionbar 選擇欄
          setactivepartition 設(shè)置活動(dòng)分區(qū)
          setupoptions 安裝選項(xiàng)
          shortcutkeys 快捷鍵
          showclipboard 顯示剪貼板
          singleside 單面
          sizemove 大小/移動(dòng)
          sorthelp S排序H幫助
          sortorder 順序

          posted @ 2006-10-07 21:22 xyang 閱讀(343) | 評(píng)論 (0)編輯 收藏

          主站蜘蛛池模板: 百色市| 辽阳市| 青冈县| 兴国县| 新津县| 吐鲁番市| 东明县| 封开县| 岗巴县| 兴宁市| 城固县| 辰溪县| 奉新县| 嘉鱼县| 章丘市| 山西省| 子长县| 鄢陵县| 鄂托克旗| 高邮市| 瓮安县| 尚志市| 和静县| 康平县| 徐闻县| 阜新| 咸宁市| 咸阳市| 迁西县| 沂水县| 安顺市| 海淀区| 普陀区| 奉节县| 汉源县| 疏附县| 鄯善县| 临夏市| 安仁县| 潜江市| 西乌珠穆沁旗|