Opened 16 months ago

Last modified 15 months ago

#13206 new Bugs

regex constructor throws regex_error for simple expression

Reported by: Asbjørn Pedersen <ahp@…> Owned by: John Maddock
Milestone: To Be Determined Component: regex
Version: Boost 1.65.0 Severity: Problem
Keywords: regex error_range Cc:


The code below throws boost::regex_error when creating an instance of boost::regex. I compile with visual studio 2015 and uses boost 1.65 precompiled for 32 bit windows (boost_1_65_1-msvc-14.0-32.exe)

#include "stdafx.h" #include <boost/regex.hpp> int main() {

try {

boost::regex re("[A-Z-.]+");

} catch (...) { assert(false); }

return 0;


Change History (1)

comment:1 Changed 15 months ago by robic@…

Error: Regex Construction .. 

Invalid range end in character class


In Perl, this compiles fine.
The dash here A-Z-. is ambiguous, it should be seen as a literal,
not a range operator.

Not all engines track this, but it is simple to do.

Note: See TracTickets for help on using tickets.