Multiple delimiters using Regex.Split in C #

Let's say you need to split the line with various delimiters, including a new line (/ r, / n) and several other special characters.

For instance:

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

I would like to get the following array of strings (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 the C # Regex.Split () function. What is a regex expression for all of my delimiters?

Thanks in advance

+3
source share
3 answers

Just FYI, the vanilla String.Split () method has an overload that takes an array of strings to use as delimiters. There is a link to an MSDN page that describes it.

+5
source

%%%|&&& must do it.

+5

Source: https://habr.com/ru/post/1748375/


All Articles