Jafe Lee

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            49 隨筆 :: 0 文章 :: 24 評論 :: 0 Trackbacks

          1、Java 正則表達(dá)式中的Quantifiers(量詞)使用來指定匹配字符出現(xiàn)的次數(shù)的,java api中有三種Quantifiers: greedy, reluctant, and possessive。雖然三種quantifiers的作用很相似(見下表),但是三者還是有區(qū)別的。(摘自java.sun.com

          Quantifiers
          ?Meaning
          ?Greedy ?Reluctant ?Possessive
          ?X? ?X?? ?X?+ ?X, once or not at all
          ?X* ?X*? ?X*+ ?X, zero or more times
          ?X+ ?X+? ?X++ ?X, one or more times
          ?X{n} ?X{n}? ?X{n}+ ?X, exactly n times
          ?X{n,} ?X{n,}? ?X{n,}+ ?X, at least n times
          ?X{n,m} ?X{n,m}? ?X{n,m}+ ?X, at least n but not more than m times


          2、幾個例子(摘自 java.sun.com
          • greedy quantifiers
          • Zero-Length Matches (1)
          • Zero-Length Matches (2)
          • Zero-Length Matches (3)
          • exactly n number of times
          • at least n times
          • an upper limit
          • Capturing Groups with Quantifiers
          • Character Class with Quantifiers

          posted on 2007-12-10 22:35 Jafe Lee 閱讀(662) 評論(2)  編輯  收藏

          評論

          # re: Java 正則表達(dá)式 (3) -- Quantifiers 2007-12-12 19:17 jeasonzhao
          展開代碼的時候有JS錯誤  回復(fù)  更多評論
            

          # re: Java 正則表達(dá)式 (3) -- Quantifiers 2007-12-12 20:41 Jafe
          @jeasonzhao
          我用firefox沒什么問題啊~
          其實(shí)這些在 java.sun.com上都有的,我也只是copy過來而已~  回復(fù)  更多評論
            


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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 阿克苏市| 盐城市| 临武县| 柳州市| 来安县| 冀州市| 郯城县| 墨脱县| 岳普湖县| 毕节市| 万源市| 如东县| 丰原市| 古丈县| 澎湖县| 保山市| 喀喇沁旗| 深水埗区| 邓州市| 嵩明县| 池州市| 神农架林区| 集贤县| 沂水县| 长沙县| 四川省| 大方县| 寻甸| 徐汇区| 遂昌县| 曲阜市| 济阳县| 清丰县| 永定县| 平泉县| 玛多县| 奉新县| 长治市| 大埔县| 太原市| 甘肃省|