2010-12-06 19 views
7

Esto es lo que he intentado:¿Se puede aumentar :: regex_search en un wstring?

std::wstring extractText(std::wstring line) { 
    std::wstring text; 

    boost::regex exp("^.*?PRIVMSG #.*? :(.+)"); 
    boost::smatch match; 

    if (boost::regex_search(line, match, exp)) { 
       text = std::wstring(match[1].first, match[1].second); 
      } 

    return text; 
    } 
+3

¿Y qué pasó cuando lo intentó? – aschepler

+0

error C2784: 'bool boost :: regex_search (const std :: basic_string &, const boost :: basic_regex &, boost :: regex_constants :: match_flag_type)': no ​​se pudo deducir el argumento de la plantilla para 'const boost :: basic_regex & 'from' boost :: smatch ' – coolface

+0

Creo que cuando uses 'std :: wstring', deberás usar las formas' w 'de boost.regex, como' boost :: wregex' y 'boost :: wsmatch'. Además, si está haciendo una coincidencia Unicode, consulte este enlace: http://www.boost.org/doc/libs/1_45_0/libs/regex/doc/html/boost_regex/unicode.html – birryree

Respuesta

14

use wregex y wsmatch

+0

nice .. that funcionó. :RE – coolface

2

Creo que sí, pero usted tendrá que usar en lugar de boost::wsmatchsmatch, y wregex también.

+0

error C2784: 'bool boost: : regex_search (const std :: basic_string &, const boost :: basic_regex &, boost :: regex_constants :: match_flag_type) ': no ​​se pudo deducir el argumento de plantilla para' const boost :: basic_regex & 'from' boost :: wsmatch ' – coolface

Cuestiones relacionadas