c#中的Split

今天qq群里有人问怎么用字符串作为分隔符,我以前只是用过Split('单个字符')的用法,没有思考过怎么用字符串作为分隔符。

我上网上查了一下,发现了一个我从来没有使用过的命名空间:System.Text.RegularExpressions.

在MSDN查询的结果是:

The System.Text.RegularExpressions namespace contains classes that provide access to the .NET Framework regular expression engine. The namespace provides regular expression functionality that may be used from any platform or language that runs within the Microsoft .NET Framework.

正则表达式。

1)、字符串分隔符


Code

显示的结果:

aaa

bbbbriiii

bbbb

2)、多个单字符分隔符

Code

显示结果:

 aaas

bbbb

iiii

bbbb

3)、单个字符分割

Code

显示结果

 aaas

sbbbbriiii

sbbbb

原文地址:https://www.cnblogs.com/lfzwenzhu/p/1286844.html