A simple batch string method

Source: Internet
Author: User

One trick is to pay tribute to Great Boost.

Specific batch rules:

The telephone number or anything else can be separated by the following four symbols:

Semicolon, for example, 1391067; 62963517, or 1391067; 62963 ;.

Comma, for example, 1391067,62963517, or 1391067,62963 ,.

Chinese semicolon, such as: 1391067; 62963, or 1391067; 629637 ;.

Chinese comma, for example, 1391067,62963, or 1391067,629617 ,.

You can also mix these four symbols, such:

1391067,6617; 62980; 1234,5678; 9900,0099;

. And so on.

In this way, the tokenizer of the boost library can be easily used.

Batch code:

# Include <boost/tokenizer. hpp>
# Include <string>

...

Std: string _ incluenfaxnumber ("629780; 038520,03851293; 1234,5678; 8989 ");

Typedef boost: tokenizer <boost: char_separator <char>

Tokenizer;

// Wholesale separator number, enumerating various symbols:

Boost: char_separator <char> sep (";,;,");

Tokenizer tokens (_ incluenfaxnumber, sep );

Tokenizer: const_iterator itBegin = tokens. begin ();

Tokenizer: const_iterator itEnd = tokens. end ();

Tokenizer: iterator tok_iter;

For (tok_iter = itBegin;

Tok_iter! = ItEnd;

++ Tok_iter)

{

_ Bstr_t bstrSingleFax (* tok_iter). c_str ());

}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.