Good day, dear professionals. I am new in regular expressions and need a hint from professionals. So.. I have std::string which contains phone nuber like "+NNNNNNNNNNNN", i.e. "+380509144161".. How can I write a regular expression to validate this value? I am using VC++ 7, boost version 1.32.0. Thank you very much in advance.
>Good day, dear professionals. I am new in regular expressions and need
>a hint from professionals. So.. I have std::string which contains phone
>nuber like "+NNNNNNNNNNNN", i.e. "+380509144161".. How can I write a regular
>expression to validate this value? I am using VC++ 7, boost
>version 1.32.0. Thank you very much in advance.I've found pretty solution:
void Class::Method(string & number)
{
static const regex r("(\\+\\d\\d\\d\\d\\d)(\\d\\d\\d\\d\\d\\d\\d)");smatch match;
if (!regex_match(number, match, r))
throw BadNumberException(number);code_ = match[0];
number_ = match[1];
}