Java uses regular to grab web mailboxes
Use regular to capture online mailboxes
This is the website we need to capture.
Implementation idea:
1. Using Java net. URL object, binding the address of a web page on the network 2. Through Java net. The openconnection () method of the URL object obtains an HTTPCONNECTION object 3. The getinputstream () method of the HTTPCONNECTION object obtains the input stream object InputStream of the network file 4. Read each line of data in the stream circularly, and match each line of characters with the regular expression compiled by the pattern object to obtain the email address
Here is our code:
Here we mainly use regular to match mailboxes:
String regex = "[a-zA-Z0-9_-]+@\\w+\\.[a-z]+(\\.[a-z]+)?";
[a-za-z0-9 -] can only contain letters, numbers, underscores and minus signs. If "+" matches [a-za-z0-9 -] one or more times, any non single character can appear after @ which is equivalent to [^ a-za-z0-9], It can be repeated one or more times, and there must be \ It's for you Do escape, and then any character between a and Z can appear after clicking.
The captured results are as follows:
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.