The reason why I want to figure this out is that I can't find all the words in a text, because when I touch C + + I remember it seems like a regex can have a lot of characters, so you can pass,. and whitespace punctuation to split the text, but the split method accepts arguments with only the string type of regex and the limit,limit of the int type to represent the maximum number of parts that can be divided into a string. Later by looking for information on the Internet to know that the original string type of regex can be composed of multiple parts, each part by | Separated, may need to appear the * +. and other symbols, may require \ \ 's escape, the specific considerations have the following parts:
1. First. * + | are key characters, and they must be escaped with \ \ to divide them.
2. Multiple split characters to connect is needed | Character
3. If you use \ as a delimiter, you have to write: Str.split ("\\\\"), because in Java is "\ \" to denote "\", the string is written like this: "String str=" a\\b\\c ";
Chestnut One:
String Str1=new string ("hello+world| I ' m*mnmlist.sting "); String regexstring= "|,|\\.| \\*|\\+|\\|"; String Arr1[]=str1.split (regexstring); for (int i=0;i<arr1.length;i++) System.out.println (Arr1[i]);
The use of the split method in Java