Multiple delimiters using Regex.Split in C#

Posted by Arthur Frankel on Stack Overflow See other posts from Stack Overflow or by Arthur Frankel
Published on 2010-06-03T15:50:20Z Indexed on 2010/06/03 15:54 UTC
Read the original article Hit count: 263

Filed under:
|

Let's say you need to split a string by various delimiters including newline (/r, /n) and a few other 'special' character strings.

For example:

This is a sample %%% text &&& that I would 
like to split %%% into an array.

I would like the following in the resulting string array (contents via index)

[0]This is a sample
[1]text
[2]that I would
[3]like to split
[4]into an array.

I would like to use C# Regex.Split() function. What is the regex expression to match on all of my delimiters?

Thanks in advance

© Stack Overflow or respective owner

Related posts about c#

Related posts about regex