Java Regular matching string fetch __java

Source: Internet
Author: User

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. */

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.