如何使用正则表达式拆分字符串 [英] How to split strings using regular expressions
本文介绍了如何使用正则表达式拆分字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想拆分首字母为F的字符串
Hi,
I want to split the string which starting first character is "F"
List<string> lstTxtAction = new List<string>();
string[] str = Regex.Split(txtAction, @"\W");
foreach (string value in str)
if (!string.IsNullOrEmpty(value))
lstTxtAction.Add(value);</string></string>
推荐答案
帮自己一个忙,不要再把随机代码放在一起然后问为什么它不起作用。
正则表达式是一个强大的工具,但你必须学习如何使用它。
阅读文档,按照示例和教程进行操作,直至理解为止。
Do yourself a favor and stop putting random code together and ask why it don't work.
Regex is a powerful tool but you have to learn how to use it.
Read documentation, follow examples and tutorials until you understand.
这篇关于如何使用正则表达式拆分字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文