Boost Users :
Subject: Re: [Boost-users] [regex] problem w/ regex::extended
From: Mark R Stallard (stallard_at_[hidden])
Date: 2015-02-13 09:03:23
U. Mutlu <for-gmane_at_[hidden]> wrote:
> the following regex expression works in perl-mode,
> but does not work in extented-mode.
It would help if you were more specific about what went wrong.
Did the constructor throw an exception?
Did the extended engine fail to match your input string?
If so, what input text are you using?
> I think I haven't used any perl-specific construct, or did I?
I only use the Perl-compatible engine myself. I check the POSIX
extended mode and did not see any obvious problems, though I did
wonder about this:
> #define WORD "[\\w\\-\\.~/]+"
I suspected that Perl would support the escape sequence \w
inside a  character set, but POSIX extended might not.
The tests I ran affirmed those suspicions.
I tested this regex in a Perl one-liner and it matched the
input string "alpha only". I tried the same regex in egrep
and it didn't work. egrep did match that input string when
I replaced "\w" with "a-z".
I find it much easier to program with regular expressions if
I test them using a command-line tool first.
|+| M a r k |+|
Business Application Services
Global Business Services Information Technology
880 Technology Drive
Billerica, MA 01821
This message contains information that may be confidential and privileged.
Unless you are the addressee (or authorized to receive mail for the
addressee), you should not use, copy or disclose to anyone this message or
any information contained in this message. If you have received this message
in error, please so advise the sender by reply e-mail and delete this
message. Thank you for your cooperation.
From: "U.Mutlu" <for-gmane_at_[hidden]>
Date: 02/12/2015 10:10 PM
Subject: [Boost-users] [regex] problem w/ regex::extended
Sent by: "Boost-users" <boost-users-bounces_at_[hidden]>
the following regex expression works in perl-mode,
but does not work in extented-mode.
What's the reason?
I think I haven't used any perl-specific construct, or did I? Where?
#define NUM "[+-]?(\\d+\\.?\\d*|\\.\\d+)([eE][+-]?\\d+)?"
#define WORD "[\\w\\-\\.~/]+"
#define EQU "\\s*\\=\\s*"
const string sUserRE_VarAndVal = WORD EQU NUM;
#define REGEX_ENGINE boost::regex::extended
#define REGEX_ENGINE boost::regex::perl
regex reNum(sUserRE_VarAndVal, REGEX_ENGINE);
Boost-users mailing list
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