将字符串解析为令牌

编程入门 行业动态 更新时间:2024-10-28 07:29:30
本文介绍了将字符串解析为令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

嗨 我如何将文件分成令牌. 是否有任何方法可以基于字符串来解析输入文件?

花一些时间来了解字符串 [ ^ ] s.

那么您可以从以下两个选项中进行选择: 1.使用 strtok/wcstok [ ^ ]函数.您可以通过调用c_str将它们播放为字符串,但这确实有点麻烦. 2.您可以在CP C ++字符串工具包(StrTk)令牌生成器中找到为这样的字符串编写的令牌生成器. a> [ ^ ].我只是随机选择了一个-尚未使用过,因此您必须尝试一下,看看是否喜欢它.如果不是,您可以随时使用本文来帮助您创建自己的解决方案. 3.您可以使用Boost令牌生成器.这与第二种解决方案非常接近,但是,您可以使用Boost :) Boost ::令牌生成器 [ ^ ] 说了这么多,我不得不承认我只使用第一种方法.我猜想这些年来,它已经发展成我了:)祝您好运!

Hi How can i break a file into tokens. Is there any method to parse the input file on basis of strings ?

解决方案

You can use "strtok" or "strtok_s" to tokenize the string.

Take some time to learn about string[^]s.

Well you have a couple of options to choose from: 1. Use the strtok/wcstok[^] functions. You can aplay them to strings by calling c_str, but it is a bit of a pain really. 2. You can get yourself a tokenizer written for strings like this one here at CP C++ String Toolkit (StrTk) Tokenizer[^]. I just picked this one at random - haven''t used it so you will have to give it a go and see if you like it. If not - you can always use the article to help you create your own solution. 3. You can use the Boost tokenizer. This is pretty close to the 2nd solution, but, you know, Boost :) Boost::Tokenizer[^] Having said all of that I have to admit I only use the first approach. It has grown on me over the years I guess :) Best of luck to you!

更多推荐

将字符串解析为令牌

本文发布于:2023-10-29 22:43:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1540980.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:令牌   字符串

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!