From 231a4c16b3dee47d026b6b176b01a9df1d43aa56 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 27 Jul 2012 12:06:08 +0200 Subject: Add support for case-insensitive regex --- cutl/re/re.cxx | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'cutl/re') 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 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:: - 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:: - 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) { -- cgit v1.1