Jafe Lee

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            49 隨筆 :: 0 文章 :: 24 評(píng)論 :: 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、幾個(gè)例子(摘自 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) 評(píng)論(2)  編輯  收藏

          評(píng)論

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

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


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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 澎湖县| 永年县| 琼结县| 余干县| 通江县| 天门市| 宜兴市| 珠海市| 义乌市| 建水县| 浑源县| 绥中县| 兴文县| 伊吾县| 油尖旺区| 布拖县| 金阳县| 平凉市| 泸水县| 甘孜县| 东山县| 禹州市| 宜都市| 南川市| 兴安县| 凤凰县| 沅江市| 永安市| 曲阳县| 伊宁市| 乳山市| 延寿县| 湘西| 洪江市| 昌黎县| 涪陵区| 秦皇岛市| 清远市| 东乡族自治县| 镶黄旗| 永安市|