The most common verification is email address verification. Websites are common. Various web scripts also use regular expressions "(Regular Expression) Verify the email address we entered to determine whether the email address is valid. Some can also separate the username and domain name. Use nowC ++The language implements email address verification.Program, Which isBoostRegular Expression Library.
Source codeAs follows:CodeAlready inG ++ 4.6.
/* * RegEx. CPP-use a regular expression to verify the email address ** boost regular expression ** copyright ye Jianfei 2012 * Compilation command: * g ++ RegEx. CPP-O RegEx-wall-lboost_regex * */ # Include <Iostream># Include <Cstdlib> # Include <String> # Include <Boost/RegEx. HPP> // Regular Expression Using Namespace STD; Using Namespace Boost; Int Main (){ String Email_address; String User_name, domain_name; RegEx pattern ( " ([0-9a-za-z \-_ \.] +) @ ([0-9a-z] + \\. [A-Z] {2, 3 }(\\. [A-Z] {2 })?) " ); // Regular Expression, matching rules: // Group 1 (username), matching rules: 0 to 9, A to Z, A to Z, underline, dot, and hyphen // Any character of, repeated once or more // In the middle, a "@" symbol // The second group (that is, the domain name), matching rules: 0 to 9 and any character in A to Z repeat or above, // Next, any character in A to Z should be repeated 2 to 3 times (such as com or CN ), // A group in the second group, a vertex, and any character from A to Z Repeat twice (such as CN or fr) // The entire group is repeated for zero or one time. // Enter the file terminator (CTRL + Z for Windows and CTRL + D for UNIX) to end the loop. While (CIN> Email_address ){ If (Regex_match (email_address, pattern) {cout < " The email address you entered is valid. " < Endl; // Intercept Group 1 User_name = regex_replace (email_address, pattern, String ( " $1 " )); // Intercept Group 2 Domain_name = regex_replace (email_address, pattern,String ( " $2 " ); Cout < " User name: " <User_name < Endl; cout < " Domain Name: " <Domain_name < Endl; cout < Endl ;} Else {Cout < " The email address you entered is invalid. " <Endl < Endl ;}} Return Exit_success ;}