如果有一段文本如下:
sdfa;阿斯顿发生大幅@@@@@@,[email protected],和[email protected],的说法的发生的发生大幅[email protected]
我要取出电子邮件:[email protected],[email protected],[email protected],[email protected]
总之,文本的内容是不可预知的,我要取出所有的电子邮件地址

解决方案 »

  1.   

    数据验证控件里有email的正则表达式,去找一下,和你的字符穿匹配
    取出匹配的字符串就可以了..
      

  2.   

    [a-z0-9A-Z_]*@[a-z0-9A-Z_]*\.[a-z0-9A-Z_]*\.[a-z0-9A-Z_]*|[a-z0-9A-Z_]*@[a-z0-9A-Z_]*\.[a-z0-9A-Z_]*
    楼主试试
      

  3.   

    A@A\.A\.A   |   A@A*\.AA  =  [a-z0-9A-Z_]* 字母 下划线 数字
    \. = .
    |  = 或
    符合 [email protected]  或 符合 [email protected] 的形式的满足条件
      

  4.   

    这个不太好取吧....没那么简单吧。
    [email protected]
    如果要是这样的一个文本,你怎么取,
    我说我信箱是[email protected]    前面和后面你怎么判断,
    我说我信箱是[email protected]   又怎么判断,
    这个没有限制,怎么找到@前的信箱名?
    我觉得无解。
    看楼下的吧。
      

  5.   

    按 11 楼的意思
    我们是不是要把 cn en 等国家代号都取出来?
    [email protected]
    cns 是一个国家名 这个  ~~?
      

  6.   

    下载PilotEdit 2.5, 新建一个文件,
    把数据拷贝到这个文件。sdfa;阿斯顿发生大幅@@@@@@,[email protected],和[email protected],的说法的发生的发生大幅[email protected]点排序按钮,选择“比较由正则表达式定义的字符串”,输入下面的正则表达式和目标字符串:
    正则表达式:[a-z|A-Z|0-9|_.]+@[a-z|A-Z|0-9|_.]+[|!a-z|!A-Z|!0-9|!_.]?
    目标字符串:%01%02%03;点“将目标字符串拷贝到剪贴板”,即可将你要的邮箱地址拷贝到剪贴板:
    [email protected];[email protected];[email protected];[email protected];
      

  7.   

    如果[email protected]  这样一个邮件,根本不知道前面到什么地方的,用正则表达能找出满足邮件格式的字符串,但如果太较真,只有你把每个邮件都发送一下试试就知道了....
      

  8.   

    用C++写为代码:CString sInput = _T("sdfa;阿斯顿发生大幅@@@@@@,[email protected],和[email protected],的说法的发生的发生大幅[email protected]");int nMailStartIndex = -1;
    int nMailEndIndex = -1;
    int nEmailSignIndex = -1;
    BOOL bEmailSignExists = FALSE; //@ exists or notfor(int i = 0; i < sInput.GetLength(); i++)
    {
    TCHAR tcharCurrent = sInput.GetAt(i);
    if( (tcharCurrent >= _T('0') && tcharCurrent <= _T('9')) || 
    (tcharCurrent >= _T('a') && tcharCurrent <= _T('z')) || 
    (tcharCurrent >= _T('A') && tcharCurrent <= _T('Z')) || 
    (tcharCurrent == _T('.') ||  tcharCurrent == _T('_') || tcharCurrent == _T('-'))
     )
     {
      if(nMailStartIndex < 0)
      {
      nMailStartIndex = i;
      }
     }
     else if(tcharCurrent == _T('@'))
     {
      if(nMailStartIndex >=0 && nMailStartIndex < i)
      {
      bEmailSignExists = TRUE;
      nEmailSignIndex = i;
      }
     }
     else
     {
      //当前字符不是邮件地址可能的字符,如果邮件开始地址存在并且“@“存在,并且@两边都存在合法的字符串,
      //我们把当前字符作为结束符并输出邮件地址。
      if(nMailStartIndex >= 0 && bEmailSignExists && nEmailSignIndex < i - 1)
      {
      TRACE(sInput.subString(nMailStartIndex, i - 1));
      }
      //重新设置标记
      nMailStartIndex = -1;
    nMailEndIndex = -1;
    nEmailSignIndex = -1;
    bEmailSignExists = FALSE;
     }
    }
      

  9.   

    用C++写为代码:CString sInput = _T("sdfa;阿斯顿发生大幅@@@@@@,[email protected],和[email protected],的说法的发生的发生大幅[email protected]");int nMailStartIndex = -1;
    int nMailEndIndex = -1;
    int nEmailSignIndex = -1;
    BOOL bEmailSignExists = FALSE; //@ exists or notfor(int i = 0; i < sInput.GetLength(); i++)
    {
    TCHAR tcharCurrent = sInput.GetAt(i);
    if( (tcharCurrent >= _T('0') && tcharCurrent <= _T('9')) || 
    (tcharCurrent >= _T('a') && tcharCurrent <= _T('z')) || 
    (tcharCurrent >= _T('A') && tcharCurrent <= _T('Z')) || 
    (tcharCurrent == _T('.') ||  tcharCurrent == _T('_') || tcharCurrent == _T('-'))
     )
     {
      if(nMailStartIndex < 0)
      {
      nMailStartIndex = i;
      }
     }
     else if(tcharCurrent == _T('@'))
     {
      if(nMailStartIndex >=0 && nMailStartIndex < i)
      {
      bEmailSignExists = TRUE;
      nEmailSignIndex = i;
      }
     }
     else
     {
      //当前字符不是邮件地址可能的字符,如果邮件开始地址存在并且“@“存在,并且@两边都存在合法的字符串,
      //我们把当前字符作为结束符并输出邮件地址。
      if(nMailStartIndex >= 0 && bEmailSignExists && nEmailSignIndex < i - 1)
      {
      TRACE(sInput.subString(nMailStartIndex, i - 1));
      }
      //重新设置标记
      nMailStartIndex = -1;
    nMailEndIndex = -1;
    nEmailSignIndex = -1;
    bEmailSignExists = FALSE;
     }
    }
      

  10.   

    CString sInput = _T("sdfa;阿斯顿发生大幅@@@@@@,[email protected],和[email protected],的说法的发生的发生大幅[email protected]");int nMailStartIndex = -1;
    int nMailEndIndex = -1;
    int nEmailSignIndex = -1;
    BOOL bEmailSignExists = FALSE; //@ exists or notfor(int i = 0; i < sInput.GetLength(); i++)
    {
        TCHAR tcharCurrent = sInput.GetAt(i);
        if( (tcharCurrent >= _T('0') && tcharCurrent <= _T('9')) || 
            (tcharCurrent >= _T('a') && tcharCurrent <= _T('z')) || 
            (tcharCurrent >= _T('A') && tcharCurrent <= _T('Z')) || 
            (tcharCurrent == _T('.') ||  tcharCurrent == _T('_') || tcharCurrent == _T('-'))
         )
         {
             if(nMailStartIndex < 0)
             {
                 nMailStartIndex = i;
             }
         }
         else if(tcharCurrent == _T('@'))
         {
             if(nMailStartIndex >=0 && nMailStartIndex < i)
             {
                 bEmailSignExists = TRUE;
                 nEmailSignIndex = i;
             }
         }
         else
         {
             //当前字符不是邮件地址可能的字符,如果邮件开始地址存在并且“@“存在,并且@两边都存在合法的字符串,
             //我们把当前字符作为结束符并输出邮件地址。
             if(nMailStartIndex >= 0 && bEmailSignExists && nEmailSignIndex < i - 1)
             {
                 TRACE(sInput.subString(nMailStartIndex, i - 1));
             }
             //重新设置标记
             nMailStartIndex = -1;
            nMailEndIndex = -1;
            nEmailSignIndex = -1;
            bEmailSignExists = FALSE;
         }
    }