Jake
Jake

Reputation: 11

Is there a bundled library for regular expressions in MSVC?

If I'm compiling a C program with gcc, I can safely assume that the functions in regex.h are available. Is there a regex library I can assume is there if someone is compiling with microsoft's C compiler?

Upvotes: 1

Views: 1284

Answers (5)

R.. GitHub STOP HELPING ICE
R.. GitHub STOP HELPING ICE

Reputation: 215193

If you want POSIX-compatible regular expression semantics (and the same API too!) then the best regex library is TRE: http://laurikari.net/tre/

Unlike most regex implementations, it follows POSIX exactly in regards to the matches it returns for parenthesized subexpressions, and it's O(n) whereas most implementations are O(2^n) in time.

Google also has a new regex implementation that uses Perl-compatible syntax if you prefer that. You can find a link on the TRE website.

Edit: By the way, TRE seems to come with project files to build it under MSVC.

Upvotes: 0

Michael Burr
Michael Burr

Reputation: 340168

C++ only, but may be something you can use (or wrap):

Visual C++ 2010 includes the TR1 regex library support.

It's also available for VC++ 2008 in a feature pack:

Upvotes: 1

nos
nos

Reputation: 229058

There's no C/C++ regexp library bundled with msvc. C++/CLI have access to the .NET regexp classes though.

Perhaps you can use PCRE

Upvotes: 0

Liu Yue
Liu Yue

Reputation: 382

Try Boost or wait for release of C++1x...

Upvotes: 0

casablanca
casablanca

Reputation: 70691

No, I don't think MSVC comes bundled with any regex library.

Regex isn't part of the C/C++ standard library, so you shouldn't rely on any compiler providing such a library by default. It's best to get hold of a separate regex library for C (I'm sure there are tons available) and include it with your code.

Upvotes: 0

Related Questions