✅ Split string on list of strings and on whathever number

Hi,
I need to split a string in substrings, splitting every time I find some specific strings (e.g. ">>>") and everytime I find a number of whathever length. I can successfully split on any of the specified string, but I cannot do it with numbers. My C# code is the following:
string value = "545: hello world: <<<example text 567 king's choice>>>";

string[] separators = new string[] {||
    "<<<", 
    ">>>", 
    ":"
}

string[] substrings = value.Split(separators, StringSplitOptions.TrimEntries);


I've tried with Regex.split as well but it includes all kind of characters, so I think it's not supposed to be used like that (https://learn.microsoft.com/en-us/dotnet/api/system.text.regularexpressions.regex.split?view=net-7.0).
Splits an input string into an array of substrings at the positions defined by a regular expression match.
Was this page helpful?