[問題] java 正規取代表示法

看板RegExp (正規表示式 Regular Expression)作者 (我是道明柏毅)時間17年前 (2008/03/10 11:14), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/4 (看更多)
我有一個字串如下: <li>( ?url = "LAB221"^^xsd:string )</li> 我只要中間的 LAB221 的部份,所以我就用底下的正規,可是比對不出來 可以請大家幫忙看看嗎? 感謝大家 // compile pattern Pattern p = Pattern.compile("<li>( \?[\\w+] = \"([A-Za-z0-9]+)\".* )</li>"); // get matcher Matcher m = p.matcher("<li>( ?url = \"LAB221\"^^xsd:string )</li>"); // test if match if (m.matches()) { System.out.println(m.group(1)); } else { System.out.println("error"); } -- ******************************************************** * Appleboy Blog * * http://blog.Wu-Boy.com/ * * Appleboy Album * * http://pic.wu-boy.com * ******************************************************** -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.123.215.42 ※ 編輯: appleboy46 來自: 140.123.215.42 (03/10 11:15)
文章代碼(AID): #17rATyHm (RegExp)
文章代碼(AID): #17rATyHm (RegExp)