A regular expression is actually a special string

Time:2020-11-16

Java regular expression provides a rich class library, which greatly simplifies the process. The following is a list of common basic syntax:
* + ? ^$[] () | / \ \ D / D / w / w {} {n} {n, m}, etc,
Note the “|” or symbol. It can match single characters and strings. For example: T [aeio] n only matches Tan, ten, tin, ton. But don’t match too, because only a single character can be matched in square brackets. To match tool, use t (a|e|i|o| o) n to realize too.
Regular expression is a skilled process, there is nothing too abstract. In fact, learning software (do not like the word “programming”) and other industries are the same, a hard indicator for programmers is the amount of code. The more code, the more familiar (or master or Master) the implementation process. Experience is not learned, just as language cannot be learned. It depends on the accumulation of a quantity. The premise of innovation is to reach a very proficient level of something. Here with friends to encourage.
(2) String support method for regular expressions: matches (regex) matches the regular expressions in brackets;

. split (regex) splits strings into character arrays. Of course, the return value is an array of characters

. replace (old string, new string) replaces the old string with a new string. It should be noted that the original string is unchanged in this substitution process, but a new string is created.

For example, string STR = ABCDE;
String str2= str.replace (“BC”, “FF”); / / change “BC” to “FF” in str“
System.out.println (STR); / / at this time, the output STR value is the same as that at the beginning of initialization
System.out.println (STR2); / / the value of STR2 becomes the desired “affde”“

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