Boost logo

Boost Users :

Subject: Re: [Boost-users] regex_replace
From: Christer Borgqvist (christer.borgqvist10_at_[hidden])
Date: 2012-02-06 10:31:51

No application crash,
the only changes is in
std::string stmp = "PORT (127,0,0,1,6,56)\r"; this works with
boost::regex regex_ip(".+\\(([0-9]{1,}),([0-9]{1,}),([0-9]{1,}),([0-9]{1,}),([0-9]{1,}),([0-9]{1,})\\).*");
std::string sip = boost::regex_replace(stmp, regex_ip, "$1.$2.$3.$4",
std::string stmp = "PORT 127,0,0,1,6,56\r"; this not.
out PORT (127,0,0,1,6,56)
if i change to
boost::regex regex_ip(".+\([0-9]{1,}),([0-9]{1,}),([0-9]{1,}),([0-9]{1,}),([0-9]{1,}),([0-9]{1,})\.*");
the out is

I must change something in the regex_ip but i cant figure it out.
  "Mauricio Gomes" <mgpensar_at_[hidden]> skrev i meddelandet
  I am not an expert in Regex but try to substitute the commas between the parenthesis by \. (backslash dot), escaping the dot.


  Note: I have not tested it.

  Hope this helps,

  On Mon, Feb 6, 2012 at 11:47 AM, Christer Borgqvist <christer.borgqvist10_at_[hidden]> wrote:


    I have a problem with the following
       std::string stmp = "PORT (127,0,0,1,6,56)\r";
       cout << stmp << endl;

       std::string sip = boost::regex_replace(stmp, regex_ip, "$1.$2.$3.$4",

       output is
       if I change to this stmp = "PORT 127,0,0,1,6,56\r";// remove the '('
    and' )'
       the output is 127,0,0,1
    what do I have to change in the boost::regex regex_ip to get dots
    instead of comma

    appreciate any help

    Boost-users mailing list


  Boost-users mailing list

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at