JAVA Regular Expressions

Source: Internet
Author: User

        String content = "1. Case Jurisdiction Issue {" Label 1 "Default content 1} Test test test test Testing {" Label 2 "Default content 2} Test test test test Test testing test Test testing testing test test"; String pattern = "\\{(". *? ") ([^,,].*?)        \\}";        Pattern P = pattern.compile (pattern);        Matcher Matcher = p.matcher (content);            while (Matcher.find ()) {String group = Matcher.group ();            int start = Matcher.start ();            int end = Matcher.end ();        SYSTEM.OUT.PRINTLN (group + "," + Start + "," + End + "\n===\n");        } String Content1 = "{" label "Default content}";        String pattern1 = "\\{" ([\\s\\s]*) "([\\s\\s]*) \ \}";        Pattern P1 = Pattern.compile (PATTERN1);        Matcher matcher1 = P1.matcher (content1);            while (Matcher1.find ()) {int matchcount = Matcher1.groupcount ();                while (matchcount >= 0) {String group = Matcher1.group (MatchCount);                int start1 = Matcher1.start (MatchCount);                int end1 = Matcher1.end (MatchCount); SYSTEM.OUT.PRINTLN (group + "," +Start1 + "," + end1);            matchcount--; }        }

JAVA Regular Expressions

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.