如果不在双引号之间如何拆分单词c#.net [英] how to splite a word if not between in double quotations c#.net

查看:60
本文介绍了如果不在双引号之间如何拆分单词c#.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI 我的搜索字符串就像
字符串str =路由器配置管理".以及框架和技术.
Iam根据空格分割字符串.

那样分割字符串 路由器配置管理"

框架

技术.
当iam在双引号之间分割字符串时,也像
一样分割 路由器
配置
管理
但我不想在双引号之间拆分单词.
必须像一个单词一样进行搜索.

HI My search string is like
string str="router configuration management" and framework and technology.
Iam splitting the string based on whitespace.
splitting the string like
"router configuration management"
and
framework
and
technology.
when iam splitting the string between the double quotation is also splitting like
router
configuration
management
but i don''t want to split the word between double quotations.
It has to be search like one word.
How to do that????

推荐答案

据我所知,这应该与.NET用于分隔命令行(如果包含引号)的算法相同分数.这不是那么容易.

如果是这样,您可以下载我的代码,该代码已发布在CodeProject上,并且经过了很好的测试.我必须开发此功能才能有效测试命令行解析,而无需多次重新启动测试应用程序(并且实际上在很短的时间内发现并修复了许多错误).

要找到此代码,请参阅我的文章基于枚举的命令行实用程序 [SA.Universal.Utilities.CommandLineSimulationUtility.阅读有关内容,并在源代码中找到该类.

请尝试一下,告诉我这是否是您需要的.

—SA
As far as I can understand, this should be the same algorithm .NET uses to split a command line if it contains quotation marks. It is not so easy to do.

If so, you can download my code which is published on CodeProject and is very well tested. I had to develop this function to be able to test command line parsing effectively without re-starting the test application many times (and actually found and fixed a number of bugs in a short period of time).

To locate this code, please see my article Enumeration-based Command Line Utility[^] and download the source code.

How to locate this function? Let''s see… In the article, see the section "6. CommandLine Testing", it explains the utility static class SA.Universal.Utilities.CommandLineSimulationUtility. Read about it and locate this class in the source code.

Please try it out and tell me if this is what you needed.

—SA


这篇关于如果不在双引号之间如何拆分单词c#.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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