如何在MFC中验证电子邮件ID [英] how to do the validation of email id in MFC
本文介绍了如何在MFC中验证电子邮件ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi ,,,
我正在验证电子邮件ID,我收到的错误很少,请告诉我哪里出了错
,,
im validating the email id im getting few errors ,,pls say where im going wrong
BOOL CMailDlg::Validate()
{
CString m_sFrom;
CString strRegex;
System::String strRegex = "^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}" + "\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\" + ".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
System::Text::RegularExpressions::Regex ^_Regex = gcnew System::Text::RegularExpressions::Regex(strRegex);
if (_Regex->IsMatch(m_sFrom))
return (true);
else
return (false);
}
错误
errors
error C2653: ''System'' : is not a class or namespace name<br />
error C2065: ''String'' : undeclared identifier<br />
missing '';'' before identifier ''strRegex''<br />
error C2110: cannot add two pointers<br />
error C2653: ''System'' : is not a class or namespace name<br />
error C2065: ''Regex'' : undeclared identifier<br />
error C2065: ''_Regex'' : undeclared identifier<br />
error C2065: ''gcnew'' : undeclared identifier<br />
error C2653: ''System'' : is not a class or namespace name<br />
error C2106: ''='' : left operand must be l-value<br />
error C2146: syntax error : missing '';'' before identifier ''Regex''<br />
error C2227: left of ''->IsMatch'' must point to class/struct/union
谢谢
推荐答案
; System :: Text :: RegularExpressions :: Regex ^ _Regex = gcnew System :: Text :: RegularExpressions :: Regex(strRegex); 如果(_Regex-& gt; IsMatch(m_sFrom)) return(true); 别的 返回(false); }
"; System::Text::RegularExpressions::Regex ^_Regex = gcnew System::Text::RegularExpressions::Regex(strRegex); if (_Regex-&gt;IsMatch(m_sFrom)) return (true); else return (false); }
错误
errors
error C2653: ''System'' : is not a class or namespace name<br />
error C2065: ''String'' : undeclared identifier<br />
missing '';'' before identifier ''strRegex''<br />
error C2110: cannot add two pointers<br />
error C2653: ''System'' : is not a class or namespace name<br />
error C2065: ''Regex'' : undeclared identifier<br />
error C2065: ''_Regex'' : undeclared identifier<br />
error C2065: ''gcnew'' : undeclared identifier<br />
error C2653: ''System'' : is not a class or namespace name<br />
error C2106: ''='' : left operand must be l-value<br />
error C2146: syntax error : missing '';'' before identifier ''Regex''<br />
error C2227: left of ''->IsMatch'' must point to class/struct/union
谢谢
尝试此链接
有效的电子邮件地址验证 [
try this link
Effective Email Address Validation[^]
这篇关于如何在MFC中验证电子邮件ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文