Hellos everyone! Here is a good one. I am using regex and am having some weird returns. I can assign my results to a std:vector std:string. The vector[0] does contain the correct match, but vector[1] does not contain what is in a set of parentheses as it should. In fact I usually get a segment fault when I try to access it. I then found I can access results from the grep by using the boost::Regex.What(n). However What(0) returns the next available match in the string, and What(1) and up will correctly report the substrings defined in this second match correctly. If no second match is available then the What() member will return the original match. How do I fix the vector problem? OR? Does using What() force another search to take place? And if so can I change that behavior? Code snippet: string reg_string ="[0-9]{3}(-[0-9]{2}-)[0-9]{4}"; //yes it is a SSN string search_string = "Big Bird \n123 sesame street \n the bronx NY 11722\n545-65-2343\nmorestuff\nandevenmore\nSnuff E Lufigous \n 234 sesame street \n the bronx NY 11722\n889-99-5527\nmorestuff\nandevenmore\n"; std::vectorstd::string results; boost::regex regsearch = boost::regex(reg_string,false); int num_matchs; num_matchs=regsearch.Grep(results, search_string, boost::match_any); cout << num_matchs << " Number of Matchs\n"; // this is 2 cout << results[0] << " results return string vector[0] \n"; // this is 545-65-2343 cout << regsearch.What(0) << " results from what(0) \n"; // this is 889-99-5527 cout << regsearch.What(1) << "results from what(1) \n";// this is -99- //this line aborts // cout << results[1] << " results return string vector[1] \n"; // this should be -65- HELP. Note I never ran the code above, but I think it is correct. __________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com
I am using regex and am having some weird returns. I can assign my results to a std:vector std:string. The vector[0] does contain the correct match, but vector[1] does not contain what is in a set of parentheses as it should. In fact I usually get a segment fault when I try to access it.
I then found I can access results from the grep by using the boost::Regex.What(n). However What(0) returns the next available match in the string, and What(1) and up will correctly report the substrings defined in this second match correctly. If no second match is available then the What() member will return the original match.
How do I fix the vector problem? OR? Does using What() force another search to take place? And if so can I change that behavior?
You are using class RegEx incorrectly:
RegEx::Grep finds all the matches of the expression in the text given and
for each match pushes $& onto the vector - if there is only one match found
then there will be only one string in the vector (check the return value or
the vectors size to find out how many there are), it does *not* push $1 $2
etc onto the vector. After a call to RegEx::Grep then RegEx::What returns
the last match that was found in the string (with What(1) containing $1 for
the last match found etc).
The following is a rewritten version of your code that actually compiles (!)
and does the right thing:
#include
Hi! I cant compile the Boost.Python library. I use Borland C++ Builder 5 (WinXP Pro). I tried really everything. I get always a LOT of errors. Here are some of my tries: No1 cd c:\libs\boost_1_30_0\libs\python\build bjam -sPYTHON_ROOT=c:\progsy\Python23 -sPYTHON_VERSION=2.3 -sTOOLS=borland i get: C:\libs\boost_1_30_0\libs\python\build>bjam -sPYTHON_ROOT=c:\progsy\Python23 -sPYTHON_VERSION=2.3 -sTOOLS=borland ...patience... ...found 1078 targets... ...updating 110 targets... borland-C++-action ..\..\..\libs\python\build\bin\boost_python.dll\borland\debug\runtime-link-d ynamic\numeric.obj ../src\numeric.cpp: Error E2401 C:\libs\boost_1_30_0\boost/python/object/inheritance.hpp 69: Invalid template argument list Error E2040 C:\libs\boost_1_30_0\boost/python/object/inheritance.hpp 69: Declaration terminated incorrectly Error E2231 C:\libs\boost_1_30_0\boost/python/object/inheritance.hpp 130: Member cast_generator
Mikołaj Dawidowski
Hi! I cant compile the Boost.Python library. I use Borland C++ Builder 5 (WinXP Pro). I tried really everything. I get always a LOT of errors.
That's because Borland C++'s template machinery is so badly broken that I've never seen it as worthwhile to find workarounds for all of the problems. A guy named Chris Trengrove was apparently working on a port some time ago which seemed to have promise but he never ended up posting results: http://aspn.activestate.com/ASPN/Mail/Message/1573361 -- Dave Abrahams Boost Consulting www.boost-consulting.com
Thanks for response.
I tried with BCB6 with the same results. So i assume i must use Microsoft or
devc++ (MinGW port). However the *.dsp file which should be OK for VS6.0
fail to open. VS60 says it is not Developer Studio 6.0 project and refuses
to open it. In my next step i converted the given *.dsp file to BCB 6.0
project file. I had to add same paths to the project and it almost compiled.
I get an error:
[C++ Error] handle.hpp(77): E2285 Could not find a match for
'detail::manage_ptr<T>(_object *,int)'
Well, i havent found any manage_ptr too in boost nor Python nor STL
directories.... so i got stuck.
Maybe someone have an idea?
The second question is: which compiler is best for compiling the
Python.Boost (DevC++ = MinGW ? or VisualC++2002 or Visual C++ 2003?). I
think once i have the dll's i can incorporate it into my applications
written in BCB.
The third question is: Is there a binary distribution of the Boost libs.
I'am talking about the sublibriaries that require it (Python, Threads,
Regex, and so on)(Regex however works good with Borland compilers).
Bye
Nick
-----Original Message-----
From: news [mailto:news@main.gmane.org] On Behalf Of David Abrahams
Sent: Sunday, July 20, 2003 3:16 AM
To: boost-users@yahoogroups.com
Subject: [Boost-Users] Re: Boost::Python compilation problem
Mikołaj Dawidowski
Hi! I cant compile the Boost.Python library. I use Borland C++ Builder 5 (WinXP Pro). I tried really everything. I get always a LOT of errors.
That's because Borland C++'s template machinery is so badly broken that I've never seen it as worthwhile to find workarounds for all of the problems. A guy named Chris Trengrove was apparently working on a port some time ago which seemed to have promise but he never ended up posting results: http://aspn.activestate.com/ASPN/Mail/Message/1573361 -- Dave Abrahams Boost Consulting www.boost-consulting.com Info: http://www.boost.org Wiki: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl Unsubscribe: mailto:boost-users-unsubscribe@yahoogroups.com Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Mikołaj Dawidowski
Thanks for response. I tried with BCB6 with the same results. So i assume i must use Microsoft or devc++ (MinGW port).
Or regular MinGW, or Metrowerks, or Intel, or Cygwin GCC or a variety of other compilers on other platforms.
However the *.dsp file which should be OK for VS6.0 fail to open. VS60 says it is not Developer Studio 6.0 project and refuses to open it. In my next step i converted the given *.dsp file to BCB 6.0 project file. I had to add same paths to the project and it almost compiled. I get an error:
[C++ Error] handle.hpp(77): E2285 Could not find a match for 'detail::manage_ptr<T>(_object *,int)'
Well, i havent found any manage_ptr too in boost nor Python nor STL directories.... so i got stuck.
Maybe someone have an idea?
Use Boost.Build. That's the most-reliable way and works with many many more compilers.
The second question is: which compiler is best for compiling the Python.Boost (DevC++ = MinGW ? or VisualC++2002 or Visual C++ 2003?). I think once i have the dll's i can incorporate it into my applications written in BCB.
Any of those will work, including vc6.
The third question is: Is there a binary distribution of the Boost libs. I'am talking about the sublibriaries that require it (Python, Threads, Regex, and so on)(Regex however works good with Borland compilers).
Not for Windows, AFAIK. -- Dave Abrahams Boost Consulting www.boost-consulting.com
participants (4)
-
David Abrahams
-
John Maddock
-
Mikołaj Dawidowski
-
sdf sdf