Recently, when I was learning Android, I used string decomposition and split, and I was cheated by regular symbols! Let’s talk about the special symbols of the regular:
/The text that indicates that it is followed is a special symbol. Example: "n" and "n" are consistent. "/n" and line breaks are consistent.
^ Consistent with the beginning of the input.
$ Ending with the characters before it; for example: ab+$ can be matched by "abb" and "ab";
* If the text before this symbol is the same as the same as the text 0 times or more, the two are the same. Example: "zo*" and "zoo", "z" are the same.
+ If the text before this symbol is the same as the text before this symbol is more than once, the two are the same. Example: "zo*" and "zoo" are consistent, but not "z".
? If the text before this symbol is the same as 0 or 1 time, the two are the same. Example: "a?ve?" and "never" are consistent.
. It is a wildcard, indicating any character, for example: "" can match "anc", "abc", "acc"; (consistent with all single literals except line breaks.)
| Or operators, for example: a[n|bc|cb]c can match "abcc", "anc", "acbc";
When decomposing using split, we should give a decomposition address'/'Decompose the following string into multiple strings, the code is as follows:
String s = “/benjaminwu198818/article/details/4023878”;
String[] s = new String[20];
String s2 = "\'";
String[] s1 = (s2);
In this way, the string can be decomposed by /. There are other regular special characters written in this way "//*", "//+"... and so on. Smart people should understand it.