sábado, 18 de agosto de 2012
Regular expression matching in C++11
A part of the boost (http://www.boost.org/) functionality regarding regular expressions has been included in the new C++11/C++0x standard.
This code works on GCC and even on Visual C++ 10 (Visual Studio 2010) and above:
std::regex rgx("(\S+@\S+)");
std::smatch result;
std::string str = std::regex_replace(std::string("please send an email to my@mail.com for more information"), rgx, std::string("<$1>"));
// str contains the same text, but with the e-mail address enclosed between <...>.
More information on regular expressions can be found here: http://www.regular-expressions.info/ .
Assinar:
Postar comentários (Atom)
Nenhum comentário:
Postar um comentário