aboutsummaryrefslogtreecommitdiff
path: root/cutl/re
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-07-27 12:06:08 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-07-27 12:06:08 +0200
commit231a4c16b3dee47d026b6b176b01a9df1d43aa56 (patch)
tree17dd0afca3ec24aac46d7579b8fbfa491624c716 /cutl/re
parente3da7b73054d94c65bb58933eae6bc82b40dd719 (diff)
Add support for case-insensitive regex
Diffstat (limited to 'cutl/re')
-rw-r--r--cutl/re/re.cxx21
1 files changed, 14 insertions, 7 deletions
diff --git a/cutl/re/re.cxx b/cutl/re/re.cxx
index 8e46d59..f2a6a67 100644
--- a/cutl/re/re.cxx
+++ b/cutl/re/re.cxx
@@ -41,7 +41,10 @@ namespace cutl
typedef tr1::basic_regex<C> regex_type;
impl () {}
- impl (string_type const& s): r (s, tr1::regex_constants::ECMAScript) {}
+ impl (string_type const& s, bool icase)
+ : r (s,
+ tr1::regex_constants::ECMAScript |
+ (icase ? tr1::regex_constants::icase : 0)) {}
impl (regex_type const& r): r (r) {}
regex_type r;
@@ -93,14 +96,16 @@ namespace cutl
template <>
void basic_regex<char>::
- init (string_type const* s)
+ init (string_type const* s, bool icase)
{
try
{
if (impl_ == 0)
- impl_ = s == 0 ? new impl : new impl (*s);
+ impl_ = s == 0 ? new impl : new impl (*s, icase);
else
- impl_->r = *s;
+ impl_->r.assign (*s,
+ tr1::regex_constants::ECMAScript |
+ (icase ? tr1::regex_constants::icase : 0));
}
catch (tr1::regex_error const& e)
{
@@ -110,14 +115,16 @@ namespace cutl
template <>
void basic_regex<wchar_t>::
- init (string_type const* s)
+ init (string_type const* s, bool icase)
{
try
{
if (impl_ == 0)
- impl_ = s == 0 ? new impl : new impl (*s);
+ impl_ = s == 0 ? new impl : new impl (*s, icase);
else
- impl_->r = *s;
+ impl_->r.assign (*s,
+ tr1::regex_constants::ECMAScript |
+ (icase ? tr1::regex_constants::icase : 0));
}
catch (tr1::regex_error const& e)
{