Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 948
aviraldg Avatar asked Sep 14 '09 09:09

aviraldg


People also ask

Is regex available in C?

It is used in every programming language like C++, Java, and Python.

What library is regex in?

<regex> library in C++ STL These classes encapsulate a regular expression and the results of matching a regular expression within a target sequence of characters.

Is regex part of the standard library?

Regex support is part of the standard library of many programming languages, including Java and Python, and is built into the syntax of others, including Perl and ECMAScript.

What regex engine does C++ use?

C++11 uses ECMAScript grammar as the default grammar for regex. ECMAScript is simple, yet it provides powerful regex capabilities.


2 Answers

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.

like image 88
Joris Timmermans Avatar answered Sep 21 '22 07:09

Joris Timmermans


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

like image 43
che Avatar answered Sep 18 '22 07:09

che