Boost logo

Boost Users :

Subject: Re: [Boost-users] [Regex] Why is my RE not working?... :-)
From: Adem (adem_at_[hidden])
Date: 2008-12-27 20:17:03


Steven Watanabe wrote:
> Adem wrote:
>>
>> Given these definitions:
>> RE: "
>> (ip=|\\(|\\[)(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})(\\]|\\)|,|;|
>> |\n)";
>> Text: "BLAH ([1.2.3.4]) [5.6.7.8] ip=100.100.200.200 BLAH2
>> (77.48.32.42)\n";
>>
>> the following code prints:
>> IP=5.6.7.8 100.100.200.200 77.48.32.42
>>
>> I wonder why it skips the first IP, ie. 1.2.3.4 ?
>> Is there something wrong in my RE definition above, the code below, or
>> in boost::regex?
>> I'm sure it's just a silly error of mine but I don't see it... :-(
>
> The problem is the leading space in the regex.

But this seems to be a problem in the regex-library, isn't it?
Even the following isn't working:
  RE = "[,; ](ip=|\\(|\\[)(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})[,; \n\\)\\]]";

ie. a comma, semicolon or blank in front.

I also explicitly stated "perl"-mode, ie:
   const char* szRe = "[,; ](ip=|\\(|\\[)(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})[,; \n\\)\\]]";
   boost::regex re(szRe, boost::regex::perl | boost::regex::icase);


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