Duplicate of: There is a function to use pattern matching (using regular expressions) in C++?
I'm not sure where one would use it... are there any parser-type functions that take some regex as an argument or something? I just found out that my editor will highlight a line after / as "regex" for C/C++ syntax which I thought was weird...
Regular Expressions are part of the C++ standard library extension defined in TR1 (see Chapter 7 in Documentation). The dinkumware library i.e has implemented the regEx extensions. I dont know about other implementations.
The extensions are simple and straight forward to use.
Boost.Xpressive allows you to write regexs as strings (like in Boost.Regex) or statically with expression templates. It is similar to Boost.Spirit for grammars.
For example, these two are equivalent:
PCRE is the de-facto standard regex library for C (and it also works in C++).
(What your editor is doing I don't know. Using a library like PCRE or any of the others suggested doesn't change the syntax of C - your regex definitions will always be held in strings.)
No, C++ does not have, and is not going to get, regexes using the /.../ syntax used in some languages. Your editor is wrong.
As all the other answers show, regex libraries for C++ do exist (And one is scheduled for inclusion in C++0x), but they process strings, delimited by ", not slashes, so they are not the reason for your editor's behavior.
If you use visual studio and portability is not a major issue, you can get results pretty quickly (no downloads, no installations) with a cute ATL facility called CAtlRegExp. It contains full and efficient RegEx parsing and matching (online sample). Haven't compared its performance to BOOST, though.
If you are in Visual Studio you can use Greta (search greta regex) but i think it's a bit slower than boost. It's really easy to use though.