Boost logo

Boost Users :

From: John Maddock (john_at_[hidden])
Date: 2006-05-17 05:23:01

Antonio Scotti wrote:
> Hi,
> I have a portability problem with regex (probably due to localization
> issues).
> I've found that, under Win32, the regular expression "\w" matches all
> the alphanumeric chars, including non ascii ones (such as e grave or
> e acute). This doesn't hold while under linux. In fact, \w only seems
> to match ascii characters. I've tried chancing the locale, but
> nothing changed.
> Is there a way to make \w have on linux the same behaviour it has on
> win32?

Sure, it all comes down to what the default C++ locale is:


called before any regexes are constructed would set the locale to "en_US"
*provided that locale is supported by your implementation*.

Alternatively, you can set the locale in specific regex instances:

boost::regex e;
e.assign(my_regular_expression); // now uses en_US as it's locale

HTH, John.

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at