Search for emails using regular expressions

Source: Internet
Author: User

<! --
Frog frog recommendation: use regular expressions to search for emails
Ask the question: Give a string, find 5 emails, and highlight the emails in red (or other display modes ),
The five emails are saved as a string separated by commas and printed out.
-->
<! Doctype html public "-// W3C // dtd html 4.0 Transitional // EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<Meta name = "Generator" CONTENT = "EditPlus">
<Meta name = "Author" CONTENT = "frog prince">
<Meta name = "Keywords" CONTENT = "frog pond">
<Meta name = "Description" CONTENT = "">
<Script language = "JScript">
Function wawa_matchmail (str)
{
/*
* --------------- Wawa_matchmail (str )-----------------
* Wawa_matchmail (str)
* Function: search for a substring that matches the mail format in a string, and return a new string that contains five searched mails separated by commas.
* Parameter: str, string type, master string to be searched.
* Instance: wawa_matchmail ("only@sohu.com, ddd, only163.com ")
* Author: Tianji, frog prince
* Update:
* --------------- Wawa_matchmail (str )-----------------
*/
// Here I use the match method of the string object.
Var re =/w + (-w +) | (. w +) * @ [A-Za-z0-9] + ((. |-) [A-Za-z0-9] + )*. [A-Za-z0-9] +/g;
Var m = MainString. match (re );
Var m1 = ""
For (var I = 0; I <m. length & I <5; I ++ ){
M1 + = m [I]. fontcolor ("blue") + ",";
}
Return (m1 );
}
Function wawa_replacemail (str)
{
/*
* --------------- Wawa_replacemail (str )-----------------
* Wawa_replacemail (str)
* Function: search for a substring that matches the mail format in a string, generate a new string, and use red to represent the part of the email.
* Parameter: str, string type, master string to be searched.
* Instance: wawa_replacemail ("only@sohu.com, ddd, only163.com ")
* Author: Tianji, frog prince
* Update:
* --------------- Wawa_replacemail (str )-----------------

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.