如何在c#中溢出字符串 [英] how to spilt the string in c#

查看:81
本文介绍了如何在c#中溢出字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

string str ='aonent / ram'



如何将此字符串拆分为三个部分,如aonnet,/,ram

请分享你的答案

解决方案

没有评论......



如何:使用拆分方法解析字符串(C#编程指南) [ ^ ]





感谢sisir patro对我的回答发表评论。



关于OP要求我建议使用 RegEx [ ^ ]模式如下: \W | \w + 。它应该返回: aonent / ram as a火柴。测试: Rad Software正则表达式设计器 [ ^ ]。



如需了解更多信息,请参阅:如何:使用正则表达式搜索字符串(C#编程指南) [< a href =http://msdn.microsoft.com/en-US/library/ms228595%28v=vs.80%29.aspxtarget =_ blanktitle =New Window> ^ ]



[/编辑]


krish这绝对可以帮到你



http://www.dotnetperls.com/split [ ^ ]



http://stackoverflow.com/questions/12200514/how-can -i-split-a-string-in-to-multiple-parts [ ^ ]



问候....:)


更精细的解决方案是使用正则表达式。



查看此链接



Regex.Split方法(字符串,字符串) [ ^ ]



有很多在线正则表达式解析器可用于生成正则表达式正确分割字符串。例如,正则表达式'\ b'可以帮助您拆分aonent和arm的单词







添加链接文字以反映文章标题。

[/编辑]

string str='aonent/ram'

how to split this string into three parts like aonnet,/,ram
Please share your answers

解决方案

No comments...

How to: Parse Strings Using the Split Method (C# Programming Guide)[^]

[EDIT]
Thank you sisir patro for your comment to my answer.

Regarding OP requirements i would suggest to use RegEx[^] with pattern like this: \W|\w+. It should returns: aonent, /, ram as a matches. Tested on: Rad Software Regular Expression Designer[^].

For further information, please, see: How to: Search Strings Using Regular Expressions (C# Programming Guide)[^]

[/EDIT]


krish this will definitely help you

http://www.dotnetperls.com/split[^]

http://stackoverflow.com/questions/12200514/how-can-i-split-a-string-in-to-multiple-parts[^]

regards....:)


The more elagent solution would to use regular expression.

Check this link

Regex.Split Method (String, String)[^]

There are plenty of online regular expression parsers available through which you can generate regular expression to correctly split the string. For example a regular expression '\b' could help you split the words that is "aonent" and "arm"


[Edit member="Tadit"]
Link text added to reflect the article title.
[/Edit]


这篇关于如何在c#中溢出字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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