You need to escape the backslash in your exp variable. Here's (1) that
works.
#include <iostream>
#include <string>
#include
using namespace std;
using namespace boost;
int main()
{
regex exp("\\s(ab)*", regbase::perl); // note the escaped \s here
cmatch what;
if ( regex_match(" ababab", what, exp) )
{
string str = what[0];
cout << str << endl;
}
}
Regards,
James
-----Original Message-----
From: Javier de Acha [mailto:jdeacha@corest.com]
Sent: Wednesday, July 23, 2003 10:50 AM
To: Boost-Users@yahoogroups.com
Subject: [Boost-Users] Problem with regular expression
Hello,
The next few lines doesn't work (1) with \s. But (2) works well [[:space:]]
regbase::escape_in_lists dont func?
Someone it knows because?
Thanks
Javier
---------------------------------------------------------------------
(1)
void main()
{
regex exp("\s(ab)*",regbase::perl);
cmatch what;
if(regex_match(" ababab", what, exp))
{
string str = what[0]; //this fail
}
}
----------------------------------------------------------------------------
----
(2)
void main()
{
regex exp("[[:space:]](ab)*",regbase::perl);
cmatch what;
if(regex_match(" ababab", what, exp))
{
string str = what[0]; //this succesfully match
}
}
[Non-text portions of this message have been removed]
------------------------ Yahoo! Groups Sponsor ---------------------~--> Buy
Ink Cartridges & Refill Kits for Your Epson at Myinks.com Free shipping on
orders $50 or more to the US and Canada.
http://www.c1tracking.com/l.asp?cid=5705&lp=home/epson.asp
http://us.click.yahoo.com/brYXfA/_xWGAA/ySSFAA/EbFolB/TM
---------------------------------------------------------------------~->
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/