Regular Expressions in Java

Source: Internet
Author: User
/* Regular expression 1. Regular expressions are an independent discipline. 2. Regular expressions are a type of character model. specifically to do string format matching. 3. Regular expressions are generic. For example, the regular expression "^a{2}$" represents 2 a characters. Equivalent to "AA" \d digital \d Non-digital \w English letter \w non-English letter */public class Stringtest07{public static void Main (string[] args) {System.out.println ("AB". Matches ("^a{2}$")); String S1 = "ASDD33DFSDAF33DDSD55FDD3DSSF4343SDF455DDSDDDH565GGGH55DDHG";//replace DD with "medium" System.out.println ( S1.replaceall ("dd", "Medium"));//replace DD with "medium" System.out.println (S1.replaceall ("d{2}", "Medium");//Replace number with "medium" System.out.println (S1.replaceall ("\\d", "Medium"));//replace non-digits with "medium" System.out.println (S1.replaceall ("\\d", "Medium"));}}


This article is from the "Gaogaozi" blog, make sure to keep this source http://hangtiangazi.blog.51cto.com/8584103/1662505

Regular Expressions in Java

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.