The target string takes out "!57m" string c = "PTUI_CHECKVC (' 0 ', '!57m ');"; Regular initialization pattern p = pattern.compile ("ptui_checkvc//('. * ', ' (. *) '/);"); The matching device initializes Matcher m = P.matcher (c); Matching query while (M.find ()) {System.out.println (M.group (1));}
One more, you can better understand group
Pattern p = pattern.compile ("ptuicb//(' (. *) ', ' (. *) ', ' (. *) ', ' (. *) ', ' (. *) ', '" () '); "); Matcher m = p.matcher (content); Log.info ("matches"); while (M.find ()) {Log.info ("match result 0:" + m.group (0)); Log.info ("Match result 1:" + m.group (1)) Log.info ("Match result 2:" + M.group (2)); log. Info ("Match result 3:" + M.group (3)); Log.info ("Match result 4:" + M.group (4)); Log.info ("Match result 5:" + M.group (5)); }/* 11:46:19,426 info [com.liuphp.qqapp.util.HeaderUtil]-matches 11:46:19,428 info [com.liuphp.qqapp.util.HeaderUtil ]-Match Results 0:PTUICB (' 0 ', ' 0 ', ' http://imgcache.qq.com/qzone/v5/loginsucc.html?para=izone ', ' 1 ', ' login successful. '); 11:46:19,428 info [Com.liuphp.qqapp.util.HeaderUtil]-Match Results 1:0 11:46:19,429 info [Com.liuphp.qqapp.util.HeaderUtil]- Match result 2:0 11:46:19,429 INFO [Com.liuphp.qqapp.util.HeaderUtil]-match result 3:http://imgcache.qq.com/qzone/v5/loginsucc.html ? para=izone 11:46:19,429 Info [com.liuphp.qqapp.util.HeaderUtil]-match result 4:1 11:46:19,429 info [ Com.liuphp.qqapp.util.HeaderUtil]-match result 5: Login succeeded. */