I have such string:
string mystr = "[email protected]|Action Required to Activate Membership for ClanTemplates|href="|">|6|6";
How to parse it to array of strings with "|" delimiter?
I have such string:
string mystr = "[email protected]|Action Required to Activate Membership for ClanTemplates|href="|">|6|6";
How to parse it to array of strings with "|" delimiter?
You can just use String.Split();
string mystr = "[email protected]|Action Required to Activate Membership for ClanTemplates|href="|">|6|6";
string[] parts = mystr.Split(new char[] { '|' });
mystr.Split() directly.Just use the Split method; no need for a regex.
string[] parts = mystr.Split('|');
If you really want to use Regex, you need to remember to escape the | as \| in raw regex, and in C#, "\\|" or @"\|".
string[] parts = Regex.Split (input, @"\|");
For something simple like this, just use string[] parts = input.Split('|'). You shouldn't use regex in this case unless there's something special, like not wanting to split on escaped pipes (like [email protected]|my value has a \| in it|more stuff'). In this example, you would use this:
string[] parts = Regex.Split (input, @"(?<!\\)\|");