tags:

views:

313

answers:

2

Hello there,

My question is simple. Is there a PHP's preg_match() function equivalent in the C++ STL?

If not, can you tell me an alternative?

Thanks.

+6  A: 

STL (till C++0x) does not supports regular expressions. But you can use boost::regex library.

Artyom
Docs located at http://www.boost.org/doc/libs/1_42_0/libs/regex/doc/html/index.html
Adriano Varoli Piazza
+3  A: 

preg_match() calls code from libPCRE. If you want the equivalent of preg_match(), then you must use that library.

Alternatively, if you just need the feature of regular expression matching (PCRE or not), there is also the Boost::regex library mentioned in another answer.

greyfade
+1 for pointing out the *exact* equivalent to preg_match(). ;-)
DevSolar
Boost.regex supports multiple regex formats. The default format is Perl compatible and hence compatible with PCRE (Perl Compatible Regular Expressions).
Ferruccio
Thanks for pointing me out. I'm now using Poco-Foundation's RegExp class that also uses PCRE. http://pocoproject.org
djzmo
@Ferruccio: Thank you, I wasn't aware of that.
greyfade
Me neither. /me bows to Ferruccio.
DevSolar