Java string Regular expression

Source: Internet
Author: User

1. Regular expressions

string substitution, example;

String s= "131hello334thrid". ReplaceAll ("[A-za-z]", "replace");

The StringTokenizer class string uses the Split () method to split the string, or you can use the StringTokenizer object to split the string, StringTokenizer not use regular expressions to split the string. Call the Java.util.StringTokenizer class when we need to parse a string and break it into separate, separate words.

StringTokenizer (string s); Constructs a parser for the string s, using the default split mark, whitespace.

StringTokenizer (string s, String delim) constructs a parser for the string s, and the characters in the parameter Delim are used as split marks.

Example: StringTokenizer fenxi=new stringtokenizer ("You are welcome");

Strintokenizer fenxi=new StringTokenizer ("You are, welcome;", ",;");

A parser can use the next Token () method to get the language symbols in a string, and whenever Nexttoken () is called, the next language symbol is obtained in the string. The Hasmoretokens () method in the Stingtokenizer class determines if there is a string. Used for loops.

2, the concept of scanner class

3. Javaweb Project System frame diagram

Java string Regular expression

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.