如何在单词中分割字符串? [英] How to split string in words?

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

问题描述


我有以下SMS信息字符串,我想从字符串中拆分Mobile no和Date&time.


@ 13,"REC READ","9021523344" ,,"2012/11/26 13:07:08 + 22"
好消息!派耶115%TT!1000 ke充值卢比,通话时间为1150卢比,通话时间为1000卢比充值karwaye.拨* 125#来检查巴恩.

Hi,
I have following SMS Information string,i want to split Mobile no and Date & time from string.


@ 13,"REC READ","9021523344",,"2012/11/26 13:07:08+22"
Great News!!Paiye 115% TT!!Rs 1000 ke recharge par Rs 1150 ka talktime,toh aaj hi apne nazdiki retailer se Rs 1000 ka recharge karwaye.Dial *125# to check baln.

推荐答案

这取决于您如何定义单词.例如,这将从字母的ASCII子集中拆分出由字符组成的单词:
It depends on how do you define what a word is. For example, this will split the words composed of the characters from the ASCII subset of the letters:
string[] words = Regex.Split(str, "[^a-zA-Z]+");



这里的想法是匹配所有不能成为单词一部分的字符子串,并由它们分开.

请参阅: http://msdn.microsoft.com/en-us/library /system.text.regularexpressions.regex.aspx [



The idea here is to match all sub-strings of characters which cannot be a part of word and split by them.

Please see: http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.aspx[^].

—SA


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

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

MSDN[^] will help you :)


使用C#的内置函数实现相同功能-> ; String.Split以,"(逗号)为基础.


谢谢,
Ambesha
use inbuild function of C# for same-> String.Split on the basis of "," (comma).


Thanks,
Ambesha


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

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