|
Boost Users : |
From: James Zappia (James.Zappia_at_[hidden])
Date: 2003-07-23 15:21:23
You need to escape the backslash in your exp variable. Here's (1) that
works.
#include <iostream>
#include <string>
#include <boost/regex.hpp>
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_at_[hidden]]
Sent: Wednesday, July 23, 2003 10:50 AM
To: Boost-Users_at_[hidden]
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_at_[hidden]> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net