Jafe Lee

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

          1、Java 正則表達式中的Quantifiers(量詞)使用來指定匹配字符出現的次數的,java api中有三種Quantifiers: greedy, reluctant, and possessive。雖然三種quantifiers的作用很相似(見下表),但是三者還是有區別的。(摘自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 閱讀(672) 評論(2)  編輯  收藏

          評論

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

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


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


          網站導航:
           
          主站蜘蛛池模板: 武城县| 麻栗坡县| 绥化市| 祁门县| 犍为县| 罗平县| 五河县| 平顺县| 莎车县| 夏河县| 澄城县| 宁晋县| 宜城市| 邮箱| 乐至县| 根河市| 清丰县| 蒲城县| 高台县| 乌恰县| 岑巩县| 永昌县| 诏安县| 临沭县| 诸暨市| 肇州县| 大安市| 温宿县| 屏边| 安乡县| 诸暨市| 得荣县| 永泰县| 乌海市| 轮台县| 敦化市| 隆昌县| 得荣县| 顺义区| 大新县| 集安市|