A string tokenizer in C++ that allows multiple separators

后端 未结 3 715
陌清茗
陌清茗 2021-02-15 16:45

Is there a way to tokenize a string in C++ with multiple separators? In C# I would have done:

string[] tokens = \"adsl, dkks; dk\".Split(new [] { \",\", \" \", \         


        
3条回答
  •  青春惊慌失措
    2021-02-15 17:04

    Use boost::tokenizer. It supports multiple separators.

    In fact, you don't really even need boost::tokenizer. If all you want is a split, use boost::split. The documentation has an example: http://www.boost.org/doc/libs/1_42_0/doc/html/string_algo/usage.html#id1718906

提交回复
热议问题