有人说c++也支持正则表达式 可是怎么用呢?
就10分了,别嫌少。

解决方案 »

  1.   

    use microsoft com   "Microsoft VBScript Regular Expression 5.5" for supporting regular expression . 
    you can find it by oleviewer.
    here is an example:
    #import "RegExp.tlb" no_namespace
    ...
    try {
      static IRegExpPtr regExp( __uuidof(RegExp) );
      regExp->Pattern = _bstr_t(lpszPattern);  HWND hWndCtrl = pDX->PrepareEditCtrl(nIDC);
      if (pDX->m_bSaveAndValidate)
      {
          int nLen = ::GetWindowTextLength(hWndCtrl);
          ::GetWindowText(hWndCtrl, value.GetBufferSetLength(nLen),nLen+1);
          value.ReleaseBuffer();      //now we verify it
          if ( regExp->Test( (LPCTSTR)value) )
          {
              IMatchCollectionPtr matches=regExp->Execute((LPCTSTR)value);
              if ( matches->Count== 1)
              {
                  IMatchPtr match = matches->Item[0];
                  if ( match->FirstIndex==0 && match->Length == value.GetLength() )
                  {
                    return;
                  }
              }
          }
          CString strMsg = CString("The input does not exactly have the pattern ") + lpszPattern;
          pDX->m_pDlgWnd->MessageBox(strMsg);
          pDX->PrepareEditCtrl(nIDC);
          pDX->Fail();
      }
      else
      {
      }
    }
    catch (_com_error& e)
    {
        AfxMessageBox( e.ErrorMessage() );
    }
      

  2.   

    你是检查Email地址格式的正确性呢?
    还是检查Email是否存在?好像说的是格式
    自己判断不行吗?就是麻烦点
      

  3.   

    找@,找.com .net等等,存不存在就不知道了,人家万一这两天坏了呢?