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 閱讀(662) 評論(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過來而已~  回復  更多評論
            


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


          網站導航:
           
          主站蜘蛛池模板: 钟山县| 阳春市| 布拖县| 桃园县| 莒南县| 祁阳县| 纳雍县| 隆子县| 白水县| 柘城县| 烟台市| 成武县| 朝阳市| 巫山县| 农安县| 南川市| 南皮县| 镇雄县| 长顺县| 许昌市| 女性| 淮阳县| 洛川县| 阿尔山市| 墨竹工卡县| 科技| 日照市| 同德县| 新河县| 胶南市| 稻城县| 辽宁省| 鄱阳县| 革吉县| 泸水县| 陆丰市| 新兴县| 黄冈市| 汶上县| 嘉义县| 贺州市|