Regular Expressions in Java programming and java Regular Expressions

Source: Internet
Author: User

Regular Expressions in Java programming and java Regular Expressions

Regular Expressions are commonly used for string processing. I don't think you need to understand them. If you want to use them, just take out the document and check it. Here is a link.

Http://www.php100.com/manual/Javascript/html/jsgrpRegExpSyntax.htm

This is a regular expression document. You can check it when using it. The following is a small example to get familiar with it. The function is to input a string and output the number of numbers in it. The code is relatively simple:

Import java. util. imports; import java. util. regex. matcher; import java. util. regex. pattern; public class reg_test1 {public static void main (String [] args) {reg_test1 rt = new reg_test1 (); rt. function ();} public void function () {int count = 0; Pattern p = Pattern. compile ("(\ d +)"); Scanner s = new partition (System. in); Matcher m = p. matcher (s. nextLine (); while (m. find () {count ++;} System. out. println (count );}}

 

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.