Let's say that I have a string that has the following:
string mystr = "*myid*-myemail-:mypwd:*myid2*-myemail2-:mypwd2:*myid3*-myemail3-:mypwd3:";
and I want to get each of the substrings that have the'*' and then add them to a new string and then get each of the values that have the ':' same with the one that has '-', and so I tried this using the split method, but it does not work.
string mystr = "*myid*-myemail-:mypwd:*myid2*-myemail2-:mypwd2:*myid3*-myemail3-:mypwd3:";
string[] myid = mystr.Split('*');
string[] myemail = mystr.Split('-');
string[] mypwd = mystr.Split(':');
string ids = "";
string emails = "";
string pwds = "";
foreach (string k in myid)
{
Console.WriteLine("THESE ARE THE IDS");
Console.WriteLine(k);
}
foreach (string k in myemail)
{
Console.WriteLine("THESE ARE THE EMAILS");
Console.WriteLine(k);
}
foreach (string k in mypwd)
{
Console.WriteLine("THESE ARE THE PASSWORDS");
Console.WriteLine(k);
}
Here is the console output:
THESE ARE THE IDS
THESE ARE THE IDS
myid
THESE ARE THE IDS
-myemail-:mypwd:
THESE ARE THE IDS
myid2
THESE ARE THE IDS
-myemail2-:mypwd2:
THESE ARE THE IDS
myid3
THESE ARE THE IDS
-myemail3-:mypwd3:
THESE ARE THE EMAILS
*myid*
THESE ARE THE EMAILS
myemail
THESE ARE THE EMAILS
:mypwd:*myid2*
THESE ARE THE EMAILS
myemail2
THESE ARE THE EMAILS
:mypwd2:*myid3*
THESE ARE THE EMAILS
myemail3
THESE ARE THE EMAILS
:mypwd3:
THESE ARE THE PASSWORDS
*myid*-myemail-
THESE ARE THE PASSWORDS
mypwd
THESE ARE THE PASSWORDS
*myid2*-myemail2-
THESE ARE THE PASSWORDS
mypwd2
THESE ARE THE PASSWORDS
*myid3*-myemail3-
THESE ARE THE PASSWORDS
mypwd3
THESE ARE THE PASSWORDS
And this is what I want it to look like:
THESE ARE THE PASSWORDS
mypwd
mypwd2
mypwd3
THESE ARE THE EMAILs
myemail
myemail2
myemail3
THESE ARE THE IDS
myid
myid2
myid3
but it does not workHow specifically does it not work?mystractually contains real email addresses & passwords?