A regular expression is actually a special string _ Regular expression

Source: Internet
Author: User
Java Regular expressions provide a richer class library and greatly simplify the process. The common basic syntax is listed below:
+ ^ $ [] () | /\ \d \d \w \w {} {n} {n,m}, etc.
Note that the "|" or symbols. It can match a single character and string. such as: T[aeio]n only match Tan,ten,tin,ton. But does not match toon, because in square brackets only can match a single character, to match Toon, use T (A|e|i|o|oo) n can realize toon.
Regular expression is a skilled process, there is nothing too abstract place. In fact, learning software (not like "programming" two words) and even other industries are the same, the programmer's one hard indicator is the amount of code. The more code you have, the more familiar (or master, or proficient) the implementation process is. Experience is not learned, just as language cannot learn. It depends on a quantity of accumulation. Ripe to be born clever (the ancients really strong, they knew this truth), the premise of innovation is a certain thing reached a very skilled degree. Here to share with friends.
(b) String's support method for regular expressions:. Matches (regex) matches regular expressions within parentheses;

. Split (Regex) segmentation string is an array of characters. Of course the return value is an array of characters

. replace (old string,new string) replaces the older string with a new string. What needs to be explained is that the original string of the substitution process is invariant, but a new string is replaced.

such as: String str= "ABCDE";
String str2=str.replace ("BC", "FF");//convert "BC" in STR to "FF"
System.out.println (str); The value of the output STR is the same as the value at the start of initialization.
System.out.println (STR2); The STR2 value becomes the desired "affde."

. ReplaceAll (regex,string) is similar to replace.

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.