/** the IP addresses in the natural order of the strings, as long as the number of bits per segment is 3. 1, according to each paragraph needs the most 0 to make up, then each paragraph will be guaranteed at least 3. 2. Keep 3 bits for each paragraph. This allows all IP addresses to be 3 bits per segment. **/import Java.util.*;class regs{public static void Main (string[] args){Ipsort ();Checkmail ();}public static void Checkmail (){String mail = "[email protected]";
String reg = "[A-za-z0-9_]+[a-za-z0-9]+ (\\.[ a-za-z]+) {1,3} ";//More exact match
reg = "\\[email protected]\\w+ (\\.\\w+) +";//relatively less accurate matching, relatively speaking generally understand, so you can also use this System.out.println (Mail.matches (reg));}Public
static void Ipsort ()
//Regular Expressions assist in the sequencing of natural order
{
String IP = "";
IP = Ip.replaceall ("(\\d+)", "00$1");
System.out.println (IP);
IP = Ip.replaceall ("0* (\\d{3})", "$");
System.out.println (IP);
string[] arr = Ip.split ("");
treeset<string> ts = new treeset<string> ();
for (String s:arr)
{
Ts.add (s);
}
for (String s:ts)
{
System.out.println (s);
}
for (String s:ts)
{
System.out.println (S.replaceall ("0* (\\d+)", "$"));
}
}}
Regular expression assistance for sorting && mailbox validation