email validation in java without regular expression
email validation in java without regular expression
Read about email validation in java without regular expression, The latest news, videos, and discussion topics about email validation in java without regular expression from alibabacloud.com
This tutorial is designed to help you navigate Java regular expressions while also helping me review regular expressions.
What is a regular expression?
The regular expression defines
Turn http://blog.csdn.net/marila4720/article/details/8728840Package URL;Import Java.util.regex.Pattern;Import Java.util.regex.Matcher;public class test1{public static void Main (String[]args) {String regex = "\ \[email protected]\\w+\\. (com\\.cn) |\\[email protected]\\w+\\. (COM|CN) ";/*\w representative [a-za-z0-9_], the reason is written \\w because \ has escaped meaning, so to output \ must be written \
Common java Regular Expression tools and Regular Expressions
The examples in this article share the code of the java Regular Expression tool class for your reference. The specific conte
In the past, there was such a question in the written test. The content was similar to the question. I knew how to do it, but I couldn't write it in the White Paper. It was immediately rejected by the Technical Manager.
This is a Java class that I have time to write for simple verification of the email format. However, regular expressions are generally used for
}? -----> Repeat M-times, non-greedy mode{m,}-------> at least m times, m+ is counted? ---------> Match Expression 0 or one time equals {0,1}A/d?b: Match AB a5b+----------> At least one time equals {1}A/d+b: Matching a2b a34b* ----------> is equivalent to {0}Character bounds: is the position, not the character^------> Character Start place^o: string starting with O$------> where the string endso$: string ending with O\b------> Not all is/w's expres
Implementation ideas:1. Use the Java.net.URL object to bind the address of a Web page on a network2. Obtain a Httpconnection object by using the OpenConnection () method of the Java.net.URL object3. Obtain the input stream object of the network file through the getInputStream () method of the Httpconnection object InputStream4. Loop through each row of data in the stream and compile the regular expression b
]+$".You can only enter a string consisting of a number, 26 letters, or underscores: "^\w+$".Verify user password: "^[a-za-z]\w{5,17}$" is in the correct format: start with a letter, length between 6~18, can contain only characters, numbers, and underscores.Verify that it contains ^% ',; =?$\ ' characters: "[^% ',; =?$\x22]+".Only Chinese characters can be entered: "^[\u4e00-\u9fa5]{0,}$"Verify email Address: "^\w+ ([-+.] \w+) *@\w+ ([-.] \w+) *\.\w+
:" + input );}}}
For example, we enter the Java email www.kevin@163.net in the command line
The output result will be: the email address cannot start with 'www. '.
If the entered email is @ kevin@163.net
The output is: the email address cannot start with '.' or '@'.
When the
Implementation ideas:1. Use the Java.net.URL object to bind the address of a Web page on a network2. Obtain a Httpconnection object by using the OpenConnection () method of the Java.net.URL object3. Obtain the input stream object of the network file through the getInputStream () method of the Httpconnection object InputStream4. Loop through each row of data in the stream and compile the regular expression b
);
System.out.println ("Commentlines:" + commentlines);
System.out.println ("Whitelines:" + whitelines);
private static void Parse (File f) {bufferedreader br = null;
Indicates whether to start Boolean comment = False for the comment;
try {br = new BufferedReader (new FileReader (f)); String Line = "";
while (line = Br.readline ())!= null) {//Remove the blank line = Line.trim () that may appear before the annotation character/*; Empty line because ReadLine () has remo
Regular expressions are a powerful and flexible text-processing tool. Using it, we can construct complex text patterns in a programmatic way, and search for input strings. Once you've found the parts that match these patterns, you'll be able to handle them as you please.About the regular expression of the syntax, the article on the internet is a lot of articles
"010-regular expresssion Matching (regular expression matching)""leetcode-Interview algorithm classic-java Implementation" "All topics Directory Index"Original QuestionImplement regular expression matching with support for '. ' an
Java Tour (34)--custom server, urlconnection, Regular expression feature, match, cut, replace, fetch, web crawler
We then say network programming, TCP
I. Customizing the service side
We directly write a server, let the local to connect, you can see what kind of effect
Packagecom. LGL. Socket;Import
, etc.). Comments start at # until the end of the line. You can enable the UNIX line mode with embedded flags.Pattern.dotall (? s) In this mode, the expression '. ' You can match any character, including a Terminator that represents a line. By default, an expression '. ' does not match the end character of the line.pattern.multiline (? m) In this mode, ' ^ ' and ' $ ' match the start and end of a row, respe
object will useMatcher ()Method to generate a Matcher instance. Then, the Matcher instance can be used to match the target String Based on the compiled regular expression. Multiple Matcher instances can share a Pattern object.
Now let's take a look at a simple example and analyze it to learn how to generate a Pattern object and compile a regular
output will be: Email address can not be ' www. ' Starting
If the input email is @kevin@163.net
The output is: The email address cannot be '. ' or ' @ ' as the starting character
When entered as: Cgjmail#$%@163.net
Then the output is:
Enter the email address contains a colon, comma and other illegal characters, please
) { Pattern p = pattern.compile ("^[0-9]{11}$"); Matcher m = p.matcher (value); Boolean IsOK = M.find (); return IsOK; }4. Create a random numberpublic static int Buildrandom (int length) {int num = 1;double random = Math.random (); if (Random 5. Get the model, browser type public static String Gettypeas (httpservletrequest request) { string typeas= request.getheader ("User-agent" ); if (Typeas.equals ("") | | Typeas==null) {typeas= "nothing";} return typeas; }5. Get the IP
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.