Boost logo

Boost Users :

Subject: Re: [Boost-users] [Regex] Why is my RE not working?... :-)
From: John Maddock (john_at_[hidden])
Date: 2008-12-28 05:11:24


Adem wrote:
>>>> 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\\)\\]]";

I had to reformat your expression to understand what was going on, but if we
write it like this:

" (ip="
  "|\\("
  "|\\[)"
"(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})"
"(\\]|\\)|,|;| |\n)"

Then it matches an IP that begins with:

* A leading space followed by *either* of:
  "ip=" or "(" or "["

But the first IP address in your text begins:

" (["

So there's no way it can match, either in Perl or in Boost.Regex.

HTH, John Maddock.


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