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.