Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is it possible to use regex in c++?

Tags:

c++

c

regex

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...

like image 947
Carson Myers Avatar asked May 02 '09 19:05

Carson Myers


2 Answers

In the vanilla C++ language there is no support for regular expressions. However there are several libraries available that support Regex's. Boost is a popular one.

Check out Boost's Regex implementation.

  • http://www.onlamp.com/pub/a/onlamp/2006/04/06/boostregex.html
  • http://www.boost.org/doc/libs/1_39_0/libs/regex/doc/html/boost_regex/syntax.html
like image 124
JaredPar Avatar answered Sep 25 '22 10:09

JaredPar


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.)

like image 45
RichieHindle Avatar answered Sep 25 '22 10:09

RichieHindle