I am having trouble splitting a string in C# with a delimiters &&
and ||
.
For example the string could look like:
"(abc)&&(rfd)&&(5)||(hh)&&(nn)||(iu)"
Code:
string[] value = arguments.Split(new string[] { "&&" }, StringSplitOptions.None);
I need to split or retrieve values in array without ()
braces - I need thte output to be
"abc" "rfd" "5" "nn" "iu"
and I need it in an array
Dictionary<string, string> dict = new Dictionary<string, string>();
dict.Add("a", "value1");
dict.Add("abc", "value2");
dict.Add("5", "value3");
dict.Add("rfd", "value4");
dict.Add("nn", "value5");
dict.Add("iu", "value6");
foreach (string s in strWithoutBrackets)
{
foreach (string n in dict.Keys)
{
if (s == n)
{
//if match then replace dictionary value with s
}
}
}
///Need output like this
string outputStr = "(value1)&&(value2)&&(value3)||(value4)&&(value5)||(value6)";