Lua is relatively powerful and always matches multiple.
t = {}for name,domain in string.gmatch(s,"([-%a%d%._]+)@([-%a%d.]+)") do -- Really no need to split and rejoin the email address -- it was a part of the demonstration. fulladdy = name .. "@" .. domain msgbox(fulladdy,'');end
CAtlRegExp seems to match only one at a time, and multiple unknown support does not support it.
# Include "stdafx. h "# include <atlrx. h> # include <atlstr. h> int _ tmain (int argc, _ TCHAR * argv []) {CString strText = "Thank you 34_9593402@qq.com" "asdfasdf @ a0" "3JDASDFG @. *) "" 16:37:18 "" asdfasdf@qq.com ~~ "" Please complain about the 495437815@qq.com. Thank you! "; CAtlRegExp <> reUrl; CAtlREMatchContext <> mcUrl; CString strRex =" {[0-9a-z \\_\\. \-] + @ [0-9a-z \\_\\. \-] +} "; // \ w + ([-+. '] \ w +) * @ \ w + ([-.] \ w + )*\. \ w + ([-.] \ w +) * REParseError status = reUrl. parse (strRex); if (REPARSE_ERROR_ OK! = Status) {// Unexpected error. return 0;} const CAtlREMatchContext <>:: RECHAR * szStart = 0; const CAtlREMatchContext <>:: RECHAR * szEnd = strText; while (TRUE) {if (! ReUrl. match (szEnd, & mcUrl) {break;} if (mcUrl. m_uNumGroups = 0) {break;} for (UINT nGroupIndex = 0; nGroupIndex <mcUrl. m_uNumGroups; ++ nGroupIndex) {mcUrl. getMatch (nGroupIndex, & szStart, & szEnd); ptrdiff_t nLength = szEnd-szStart; printf ("% d: %. * s \ n ", nGroupIndex, nLength, szStart);} // end for} // end while return 0 ;}