Does C or C++ have a standard regex library?

前端 未结 9 787
梦毁少年i
梦毁少年i 2021-02-05 10:36

Does it? If yes, where can I get the documentation for it... if not, then which would be the best alternative?

相关标签:
9条回答
  • 2021-02-05 10:46

    Under UNIX-like systems you can use POSIX regex functions.

    0 讨论(0)
  • 2021-02-05 10:46

    The Microsoft Visual C++ 2008 Feature Pack 1 (now rolled into the Visual Studio 2008 Service Pack 1) contains a implementation of the 'official' TR1 reg ex types. Knock yourself out :-)

    0 讨论(0)
  • 2021-02-05 10:50

    The standard ISO/IEC 14882:2011 Programming Language C++ describes a regex class as part of C++'s library, which is heavily influenced by the mature Boost library.

    Curiously, as of January 2013, compilers' compliance with this standard is still spotty, e.g. the GNU compiler suite's popular C++ compiler does not support/comply with this part of the standard.

    For that reason, it's best to use Boost at this point in time until compiler support reaches compliance.

    0 讨论(0)
  • 2021-02-05 10:55

    Qt, from Trolltech, also has a regex implementation which I find very easy to use. However, if you are not planning of using Qt for anything else I would use Boost.Regex as you probably would be good off using Boost for other purposes as well.

    0 讨论(0)
  • 2021-02-05 11:01

    Check the boost regex library. It should become part of the standard with C++0x.

    0 讨论(0)
  • 2021-02-05 11:05

    C++11 now finally does have a standard regex library - std::regex.

    If you do not have access to a C++11 implementation, a good alternative could be boost regex. It isn't completely equivalent to std::regex (e.g. the "empty()" method is not in the std::regex) but it's a very mature regex implementation for C++ none the less.

    0 讨论(0)
提交回复
热议问题