Re: CAtlRegExp kind of hangs with some expressions
"Abubakar" <emailallrise@yahoo.com> wrote in message
news:%23YoK7XPeHHA.4004@TK2MSFTNGP06.phx.gbl...
Hi,
I'm using the following code (using the reg exp you posted) and it keeps
returning me "invalid email", the Match() is not returning true::
CAtlRegExp<> re;
TCHAR * atlgroup =
TEXT("\\s*(([\\w\\-]{1,}(\\.{0,}[\\w\\-]{1,}){0,}@[\\w\\-\\.]{0,}\\.[a-z]{2,5})[;,]\\s*)*([\\w\\-]{1,}(\\.{0,}[\\w\\-]{1,}){0,}@[\\w\\-\\.]{0,}\\.[a-z]{2,5})\\s*");
re.Parse (atlgroup);
CAtlREMatchContext<> mc;
if (re.Match (TEXT(abc@gmail.com), &mc))
{
cout<<"valid ";
}
else
{
cout<<"invalid ";
}
cout<<"email.";
What am I doing wrong?
Your code fragment is bad, of course.
if (re.Match (TEXT(abc@gmail.com), &mc))
should be
if (re.Match (TEXT(abc@gmail.com), &mc))
Fixing that, and the code works for me.
Brian
..ab
"Brian Muth" <bmuth@mvps.org> wrote in message
news:e5KlTNMeHHA.4964@TK2MSFTNGP04.phx.gbl...
This monster is one of my favourites (warning, when this posts I'm
expecting to break over lines)
\s*(([\w\-]{1,}(\.{0,}[\w\-]{1,}){0,}@[\w\-\.]{0,}\.[a-z]{2,5})[;,]\s*)*([\w\-]{1,}(\.{0,}[\w\-]{1,}){0,}@[\w\-\.]{0,}\.[a-z]{2,5})\s*
It will accept multiple email addresses, separated by either commas or
semicolons.
Brian