boost::regex_replace for complete dummies

O

oxkfame

This is the first time that I ever needed to use regex from C++, and
while boost has the library, I am at a complete loss. What am I doing
wrong?
cout << boost::regex_replace(string("[^]"),
boost::regex("\(\[\)\(\.\*\)\(\]\)"),
string("$2")) << endl;

Shouldn't it print ^ ?

I realize that I am missing something in my knowledge, I just wish I
knew what.

Thank you in advance.
 
O

oxkfame

Start by writing the regular expression, just as you'd type it into a
text editor:

        \[(.*)\]

Then turn it into a quoted string, escaping the backslashes:

        "\\[(.*)\\]"

(written but not tested).

--
   Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of
"The Standard C++ Library Extensions: a Tutorial and Reference"
(www.petebecker.com/tr1book)

You rock. I get it now, and it absolutely worked like expected.

Thank you SO much.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,831
Latest member
HealthSmartketoReviews

Latest Threads

Top