Regular Express in VC???

  • Thread starter Thread starter Mohammad Omer
  • Start date Start date
M

Mohammad Omer

Hi,

i want to use regular expression in my project for validation of
email. How i can use Regular Expression in VC?? i am using vs2k5 IDE.
i seen boost api for regular expression, is it any regular expression
functionality available in VC ???? if yes, how i can use them???


regards,
-aims

..
 
Hi,

i want to use regular expression in my project for validation of
email. How i can use Regular Expression in VC?? i am using vs2k5 IDE.
i seen boost api for regular expression, is it any regular expression
functionality available in VC ???? if yes, how i can use them???

If you're doing managed programming (ie, using C++/CLI and the .NET
framework), there is regular expression support in the framework.

If you're doing native coding, there is a regex engine in ATL server :
see http://msdn2.microsoft.com/en-us/library/wzck77h4(VS.80).aspx
Anyway, I would rather recommend to use boost...

Arnaud
MVP - VC
 
i want to use regular expression in my project for validation of
email. How i can use Regular Expression in VC?? i am using vs2k5 IDE.
i seen boost api for regular expression, is it any regular expression
functionality available in VC ???? if yes, how i can use them???

Try http://www.pcre.org/ -- Perl Compatible Regular
Expressions. It's available with full source code, and has a BSD
license (making it quite easy to distribute with any of your apps).
It's been used in a lot of well-known software projects. It'd probably
be easier to integrate than boost.

Nathan Mates
 
Hi Cholo Lennon!

i found these line of code for using regular expression in VC, please
guide me, Is this right to use it or use some other API for the
regular expression??

Code is:

#include <atlrx.h>

CAtlRegExp<> re;
re.Parse(TEXT("\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"));
CAtlREMatchContext<> mc;
if(!re.Match(singleEmail, &mc))
{
retStatus = FALSE;
break;
}

Regards,
-aims
 
Those lines use ATL server library (check Arnaud response). In general all regex libraries use the same concepts so it's easy to
port those code to other libraries.
ATL server is part of VC 7 (or above) so it's fine to use it. If you want portability to other plattforms you can use boost
libraries (http://www.boost.org/libs/regex/doc/index.html) or like Nathan Mates said, Perl Compatible Regular Expressions.


Regards
 
Back
Top