C中的一个字符串标记++,它允许多个分离器 [英] A string tokenizer in C++ that allows multiple separators

查看:92
本文介绍了C中的一个字符串标记++,它允许多个分离器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:结果
C ++:如何分割字符串






有没有一种方法来标记在C ++字符串有多个分隔符?在C#中我会做:

 的String []标记=ADSL,dkks; DK.Split(新[] { ,,,;},StringSplitOptions.RemoveEmpty); 


解决方案

使用的boost ::标记生成器。它支持多种分隔符。



其实,你真的不甚至不需要提振::标记生成器。如果你想要的是一个分裂,使用boost ::分裂。该文档有一个例子:
HTTP ://www.boost.org/doc/libs/1_42_0/doc/html/string_algo/usage.html#id1718906


Possible Duplicate:
C++: How to split a string?

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 [] { ",", " ", ";" }, StringSplitOptions.RemoveEmpty);

解决方案

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

这篇关于C中的一个字符串标记++,它允许多个分离器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆