-1

I need to split a string in this form

[delimA][delimB]\n1delimA2delimB3

for example if I have

[***][%]\n1***2%3

it should return an array of

1 2 3

How can I do this?

Lx2pwn
  • 313
  • 4
  • 11

1 Answers1

5

You don't need a regular expression for this. String.Split can accept multiple delimiters, eg :

var line="[***][%%]";
var parts=.Split(new[]{'[',']'},StringSplitOptions.RemoveEmptyEntries);

StringSplitOptions.RemoveEmptyEntries as the name explains, will remove any empty entries after splitting

Panagiotis Kanavos
  • 120,703
  • 13
  • 188
  • 236