Example #1
0
// convert escape char to literal char
ucs4string ConvertEscape(const ucs4string &str)
{
    ucs4string out;
    detail::escape_value<ucs4_t, ucs4_regex_traits::char_class_type> esc;

    ucs4string::const_iterator begin=str.begin();
    ucs4string::const_iterator end=str.end();
    compiler_traits<ucs4_regex_traits> ucs4traits;

    while(begin!=end)
    {
        if(*begin=='\\')
        {
            if(++begin == end)
            {
                //out.push_back('\\'); // last char is '\'
                throw regex_error(regex_constants::error_escape);
            }
            else
            {
                esc = detail::parse_escape(begin, end, ucs4traits);
                out += esc.ch_;
            }
        }
        else
        {
            out += *begin;
            ++begin;
        }
    }

    return out;
}