Regular Express in VC???

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

..
 
A

adebaene

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
 
N

Nathan Mates

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
 
M

Mohammad Omer

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
 
C

Cholo Lennon

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top