Reputation: 6402
I have this Regular Expression : [E](((\d{1,2})))[-][E]?(\d{1,2})
which I use on this string S03E01-E03
It works well.
When I use regexstorm.net to test my expression with they generate a "split list" how can this be done in c#?
Upvotes: 0
Views: 1157
Reputation: 21641
Use Regex.Split()
.
string regex = @"[E](((\d{1,2})))[-][E]?(\d{1,2})";
string s = "S03E01-E03";
Regex rgx = new Regex(regex);
string[] splitResults = rgx.Split(s);
foreach (var str in splitResults)
{
Console.WriteLine(str);
}
Console.ReadLine();
Upvotes: 2
Reputation: 2052
Using Regex.Split
var regex = new Regex("[E](((\\d{1,2})))[-][E]?(\\d{1,2})");
var substrings = regex.Split("S03E01-E03");
that will split out your string into a String[].
Upvotes: 3