Dave,
I am using 10.5.2 and Xcode 3.0 and it compiles and runs fine for me. 
I know that isn't much help but its does add weigh to the idea that the test case isokay from a stability point. However...

 
 I changed the the HTML source adding a simple script: "<html><head><script src=\"script.js\"></script><title>Some title</title></head><body>Hello, world!</body></html>" (don't worry the escaped double quotes don't appear in the actual string object -- I verified with the debugger) and although my Regex tester in the Komodo IDE shows a group match for regex, the substitution fails for some reason. I'll need to look at the docs; perhaps you need to add some error checking--something isn't right.

 
Daniel

-- 
Some people building C++/Obj-C code on OS X with Xcode and who have a problem to solve think: "I know, I'll use the Boost Libraries". Now they have two problems--three if they are planning on using Boost for regular expressions.

 

 

On 3/12/08, Dave DeLong <davedelong@gmail.com> wrote:
My platform is Mac OS X 10.5.2.  I'm compiling and running via Xcode 3.0.  Boost is version 1.34.1 (I installed it in the last two weeks).  It was compiled on this machine by running "sudo make install", which installed it in /usr/local/include/boost.  The library files are in /usr/local/lib.  In my project specification, I specify those paths in my Library and Header search paths, and also add the linker option "-lboost_regex".

 
The following code gets a EXC_BAD_ACCESS error and never executes the catch blocks:  (I realize that the pageSource doesn't actually have a <script> tag;  That's because I don't know if the pages I'll be parsing will have one.  However, the code still fails even if there is a <script>TESTSCRIPT</script> tag in there.)

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

 
using namespace std;

 
int main (int argc, char * const argv[]) {
string * pageSource = new string("<html><head><title>Some title</title></head><body>Hello, world!</body></html>");
try {
boost::regex tagRegex("(?:i)<script[^>]*>.*?</script[^>]*>");
string replaced = boost::regex_replace(*pageSource, tagRegex, " ", boost::match_default);
delete pageSource;
pageSource = new string(replaced);
} catch (exception &e) {
cout << e.what() << endl;
} catch ( ... ) {
cout << "Unknown exception" << endl;
}


cout << *pageSource << endl;


delete pageSource;
    return 0;
}


 
Any help would be greatly appreciated, as this project is due tomorrow.  =)

 
Thanks,

 
Dave

 
On 12 Mar, 2008, at 7:50 AM, John Maddock wrote:

Dave DeLong wrote:
Ah, you're right.  That was one of my attempts to fix it (which you
can guess didn't work).

As for the inefficiency, this is my first stab at regex.  =)

Here's the complete function as it stands (or doesn't, since it still
crashes):

void Page::removeScriptTags() {
boost::regex tagRegex("(?:i)<script[^>]*>.*?</script[^>]*>");
string source(*pageSource);
string replaced = boost::regex_replace(source, tagRegex, " ",
boost::match_default);
delete pageSource;
pageSource = new string(replaced);
}

That looks fine as it stands, but unless you can reduce it to a complete
test case that I can compile and run here it still doesn't help much.  Also
what compiler, platform and Boost version are you using?  Also please check
that there isn't some binary-compatibity issue going on: building your app
with different options than Boost was built with, or linking to a library
file that's from a different Boost version to the headers you're #including
etc...

John.

_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

 

_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users