
Hello, I'm using boost::regex 1.34.0 and experience behaviour with mixed greedy and non-greedy operators in the same expression which I do not understand. I have either one of the following input strings: user1@hostname.com user2 and want to keep only the usernames, so I use the following expression: (.*?)(@.*)? with the format string $1. I would expect that basically the regex machine would first try to satisfy the greedy operator "?", and then fill up the non-greedy "*?" with the remaing part of the input. However, the following does NOT work (the hostname is not removed): std::string output; output = boost::regex_replace(std::string("user1@hostname.com"), boost::regex("(.*?)(@.*)?"), std::string("$1"), boost::regex_constants::format_first_only); However, if I omit the "format_first_only", it works as expected. What do I miss? Thanks, Arne ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program.