Boost logo

Boost Users :

Subject: [Boost-users] Regular Expression (vers. 1.34.1)
From: Salvatore Benedetto (salvatore.benedetto_at_[hidden])
Date: 2010-05-05 07:54:59


Hi there,

I'm trying to use boost regular expression for the first time
and I'm having some trouble getting it right.

Current I'm trying to find all files with the a certain extension
(by also using boost::filesystem), which should be simple,
but I'm probably missing something.

Here is the expression I'm using.

boost::regex regularExpression;
std::string expression("\.\/\w+(\.txt)");
try {
    regularExpression.assign(expression, boost::regex_constants::icase);
...
std::string testAgainst((*iterPath).string());
if (boost::regex_match(testAgainst, regularExpression))
...

which (I thought) should match all string with the pattern "./filename.txt"
but it does not. Using "\.\/\ReadMe(\.txt)" for example, correctly
matches the ./ReadMe.txt file, so the \w+ seems not do what I'm
reading from [1] where (\w+\.) is used to match part of a URL.

Anyone can shine some light on this, or point me to another good
reading about regular expression with boost?

Note: I'm using version 1.34.1 because I have to.

Thanks,
S.

[1] http://onlamp.com/pub/a/onlamp/2006/04/06/boostregex.html


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