|
Boost Users : |
Subject: [Boost-users] boost::regex Character set including braces
From: Tobias (i_at_[hidden])
Date: 2013-12-04 04:27:48
Dear boost-users,
in the post
http://stackoverflow.com/questions/20351369/regular-expression-cant-find-seq
uence-of-numbers
I discovered that if one uses an closing bracket as the first character of a
character class the character class includes this bracket.
This works with the standard setting of boost::regex (i.e., perl-regular
expressions) but it is not documented in the
manual page
http://www.boost.org/doc/libs/1_55_0/libs/regex/doc/html/boost_regex/syntax/
perl_syntax.html#boost_regex.syntax.perl_syntax.character_sets
Is this an undocumented feature, a bug or did I misinterpret something in
the manual?
The version information in version.hpp is:
#define BOOST_LIB_VERSION "1_53"
Info: I tried this specification of the bracket in the character set because
I am used to it from emacs regular expressions.
In the remainder there follows a program for reproduction of the phenomenon:
#include <string>
#include <boost/regex.hpp>
#include <iostream>
using namespace std;
int main()
{
std::cout << "main()\n";
string s = "98[2]00";
string exp = "^[][0-9]*$";
const boost::regex e(exp);
bool isSequence = boost::regex_match(s,e);
//isSequence is boolean and should be equal to 1
cout << isSequence << endl;
return 0;
}
/**
Local Variables:
compile-command: "g++ -g test.cc -o test.exe -lboost_regex-mt;
./test.exe"
End:
*/
Best regards / Mit freundlichen Grüßen
Tobias Zawada
Engineering / Software Development
______________________________
ITI Events
We say Thank you! for an outstanding ITI Symposium 2013!
Make sure you save the date for next year: November 3-5, 2014
www.itisim.com
ITI GmbH
Schweriner Straße 1
01067 Dresden Germany
T +49 (351) 26050 147
F +49 (351) 260 50 155
mailto:Zawada_at_[hidden]
Managing Director/Geschäftsführer
Jens O. Schindler · Dr. Andreas Uhlig
Commercial Register/Handelsregister
Amtsgericht Dresden · HRB 2331
USt.-IdNr.: DE140297717
Diese E-Mail ist streng vertraulich und nur für den Empfänger bestimmt. Sie
kann Informationen enthalten, die rechtliche, geschäftliche oder andere
Vergünstigungen bedeuten. Sollten Sie nicht der ausdrückliche Empfänger
sein, dürfen Sie diese Informationen nicht benutzen, veröffentlichen oder
vervielfältigen.
The information in this e-mail is strictly confidential, is intended solely
for the addressee, and may be privileged. If you are not the intended
addressee you must not disclose, print or take action based upon this
transmission and should delete it from your system.
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