Package RegEx; import Java. util. regEx. *; import Java. util. *; public class regexget {public static void main (string ARGs []) {// get (); // test_1 (); test_2 ();} public static void get () {string STR = "Good good study, day up"; string RegEx = "\ B [a-Z] {4} \ B "; // take the word pattern P = pattern, which consists of four characters. compile (RegEx); // system. out. println (p); matcher M = P. matcher (STR); While (M. find () {system. out. println (M. group () + M. start () + "---" + M. end () ;}}/** Exercise 1 * Will me ...... to be ....... learning ...... learning ....... compile .......... process to * I want to learn programming **/public static void test_1 () {string STR = "I am ...... to be ....... learning ...... learning ....... compile .......... cheng "; // replace all vertices in string RegEx = "\\. + "; STR = Str. replaceall (RegEx, ""); // The following will repeat only one RegEx = "(.) \ 1 + "; STR = Str. replaceall (RegEx, "$1"); system. out. println (STR);}/* Exercise 2 * sorts the given IP addresses * 192.68.1.254 102.49.23.13 10.10.10.10 2.2.2.2. 8.109.90.30 **/public static void test_2 () {string IP = "192.68.1.254 102.49.23.13 10.10.10.10 2.2.2.2 8.109.90.30 "; // Add 0 string RegEx = "(\ D +)" to each IP bit first; IP = IP. replaceall (RegEx, "00 $1"); // retain only three RegEx = "0 * (\ D {3})"; IP = IP. replaceall (RegEx, "$1"); // cut string [] result = IP. split ("+"); arrays. sort (result); system. out. println ("after"); For (INT I = 0; I <result. length; I ++) result [I] = Result [I]. replaceall ("0 * (\ D +)", "$1"); // remove the previous 0 for (string S: result) system. out. println (s );}}