Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 03-06-2006, 05:55 AM   #1
Registered: Aug 2004
Posts: 137

Rep: Reputation: 15
Do we have regular expression in C++ ?


I am looking to make a program in C++ which will be greatly solved by using regular expressions. Does C++ have default support of regular expression(i.e. inbuilt library) or do I need to get some external library to use it ? I am working on DevC++,windows by the way.A example will be really helpful.

Old 03-06-2006, 06:26 AM   #2
Registered: Aug 2005
Location: Germany
Distribution: Ubuntu, Debian
Posts: 189

Rep: Reputation: 31
Well, I haven't used it for myself so far, but I know that the great "boost-library" ( offers a class for regular expressions. This library is also known to be very good documented, so you will surely get along with it.
Old 03-06-2006, 09:53 AM   #3
Registered: Mar 2004
Location: Massachusetts
Distribution: Debian
Posts: 557

Rep: Reputation: 42
There's also a C way to do it -- man 3 regex . I'd imagine the boost library makes it look better
Old 03-06-2006, 10:33 AM   #4
Registered: Aug 2004
Posts: 137

Original Poster
Rep: Reputation: 15
Hi, I have installed Boost for VC6 and refered to some online code. I have already added the library for VC6 and the code is giving me the following error:fatal error C1083: Cannot open include file: 'boost\function.hpp': No such file or directory All the paths are fine I guess..what can be the problem than.I hope asking such questions do not violate policies of LQ

#include <iostream>
#include <string>
#include <boost/shared_ptr.hpp>
using namespace std;
int main () {
  int i;
  string str="hello world";

  static const boost::regex e("hello world");
   i=regex_match(s, e);
	   cout << "not matched";
  return 0;
Old 03-06-2006, 10:54 AM   #5
Registered: Aug 2005
Location: Germany
Distribution: Ubuntu, Debian
Posts: 189

Rep: Reputation: 31
Are you sure, that your paths are correct? It looks to me, that you didn't add the boost directory (that contains the headers) to your include paths. So look where "boost\function.hpp" is located on your system and add this directory (the one that contains the "boost" subdirectory) to your include paths. It's a long time ago, since I last worked with VC6, but you should find these paths-settings somewhere under the menu Options/Projects/Directories/Include, or something similar.

Oh, and you should also add
#include <boost/regex.hpp>
And change the "s" (first parameter of 'regex_match') to "str". After doing so, the program worked fine for me. And don't forget to link against the boost regex library.

Last edited by Flesym; 03-06-2006 at 11:31 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with regular expression aecaudel Programming 6 11-04-2005 06:28 AM
Anyone know regular expression? ahhua Linux - Software 1 12-04-2003 09:13 AM
Regular Expression Help WeNdeL Linux - General 1 08-14-2003 11:08 AM
Regular Expression slizadel Programming 4 07-28-2003 06:16 AM
regular expression gumby Programming 3 07-15-2003 01:13 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:25 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration