By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,137 Members | 1,024 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,137 IT Pros & Developers. It's quick & easy.

simple failure of boost::regex

P: n/a
I have installed boost 1.33.1 and everything compiled and installed
fine on Windows using Visual C++ 8.0.

I wrote the following simple code to test the regex library and it
doesn't seem to work. In the following "Matched" is not output to
cout.

Am I missing something or do I have a problem with my regex install?

#include <string>
#include <boost/regex.hpp>

using namespace boost;
using namespace std;

int main()
{
string s("hello world");
regex e("hello");

cout << "Testing regex match" << endl;
if (regex_match(s, e)) {
cout << "Matched" << endl;
}

return 0;
}

Mar 13 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Alan Patterson" ,comp.lang.c++:
int main()
{
string s("hello world");
regex e("hello");

cout << "Testing regex match" << endl;
if (regex_match(s, e)) {
cout << "Matched" << endl;
}

return 0;
}
regex_match only returns true for regexps matching the entire string;
you're looking for regex_search.
Mar 13 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.