 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
greenuri Guest
|
Posted: Wed Mar 09, 2005 5:38 am Post subject: [Nuri] How can i use Boost 1.32 |
|
|
Hi there.
I'm using bcb6 sp4 and i wanna to use boost 1.32.
So I get Boost Library from www.boost.org
and install it.
bjam "-sTOOLS=borland"
but simple regex library example doesn't correctly
#include <iostream>
#include <locale>
#include <boost/regex.hpp>
using std::cout;
using std::wcout;
using std::endl;
void test_search() {
cout << "nregex_search for const char*" << endl;
{
const char* source = "
href='http://www.roguewave.com:80/index.html'>here</a>";
boost::reg_expression<char> regex;
regex.set_expression("(([a-z]+) ? //([^:/]+)( [0-9]+))? /([a-zA-Z.
0-9]*)");
regex.str().assign("(([a-z]+) ? //([^:/]+)( [0-9]+))? /([a-zA-Z.
0-9]*)");
boost::match_results<const char*> results;
cout << "URL = " << source << endl
<< "regex = " << regex. str() << endl;
if ( boost::regex_search(source, results, regex) ) {
cout << " scheme :" << results. str(2) << endl
<< " host :" << results. str(3) << endl
<< " port :" << results. str(5) << endl
<< " path :" << results. str(6) << endl;
} else {
cout << "no match. " << endl;
}
}
cout << "nregex_search for std::string" << endl;
{
std::string source = "
href='http://www.roguewave.com:80/index.html'>here</a>";
boost::reg_expression<std::string::value_type> regex;
regex.str().assign("(([a-z]+) ? //([^:/]+)( [0-9]+))? /([a-zA-Z.
0-9]*)");
boost::match_results<std::string::const_iterator> results;
cout << "URL = " << source << endl
<< "regex = " << regex. str() << endl;
if ( boost::regex_search(source, results, regex) ) {
cout << " scheme :" << results. str(2) << endl
<< " host :" << results. str(3) << endl
<< " port :" << results. str(5) << endl
<< " path :" << results. str(6) << endl;
} else {
cout << "no match. " << endl;
}
}
}
int main() {
std::locale::global(std::locale("korean"));
test_search();
return 0;
}
This example source Result is
regex_search for const char*
URL =
regex = (([a-z]+) ? //([^:/]+)( [0-9]+))? /([a-zA-Z. 0-9]*)
scheme :http
host :www.roguewave.com
port :80
path :index.html
but in my Bcb6
Result is doesn't match
ooops
i'll be crazy
some one help me
how to install boost library in Borland C++ Builder 6?
|
|
| Back to top |
|
 |
Thomas Maeder [TeamB] Guest
|
Posted: Wed Mar 09, 2005 8:54 am Post subject: Re: [Nuri] How can i use Boost 1.32 |
|
|
"greenuri" <greenuri (AT) pmbinfo (DOT) com> writes:
| Quote: | const char* source = "<a
href='http://www.roguewave.com:80/index.html'>here</a>";
boost::reg_expression<char> regex;
regex.set_expression("(([a-z]+) ? //([^:/]+)( [0-9]+))? /([a-zA-Z.
0-9]*)");
regex.str().assign("(([a-z]+) ? //([^:/]+)( [0-9]+))? /([a-zA-Z.
0-9]*)");
|
Both these expressions have blanks after the question marks which
shouldn't be there.
I think there are other errors, as well. E.g. a colon with no port may
follow the host name; and you disallow capital characters and digits
in host names.
When I first had to parse URIs, I started from the regular expression
from Annex B of http://www.ietf.org/rfc/rfc2396.txt and added support
for the port after the host name. I have come up with
boost::regex const URIexp("(? [^:/?#]+) ?"
"(?://([^/?#:]*)(?: [^/?#]*))?)?"
"([^?#]*)"
"(\?([^#]*))?"
"(#(.*))?");
I'd write [?] rather than \? on the 4th line of the expression if I
wrote that expression now, but it seems to work well.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|