开发者

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开发者_C百科 regex library I can assume is there if someone is compiling with microsoft's C compiler?


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

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

  • http://msdn.microsoft.com/en-us/library/bb982382.aspx

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

  • http://www.microsoft.com/downloads/details.aspx?FamilyId=D466226B-8DAB-445F-A7B4-448B326C48E7&displaylang=en


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.


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


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜