Hello
There,
How can one separate a text into 2 columns (FirstName and LastName).
The only Hint I have is the UpperCase of the second name.
Eg. EdwardJohn I want it to be Edward in one column and John in the second column.
Any help shall be appreciated
Loading
Naresh ChPosted Dec 21, 2012, 5:38 AM
Edward MunyaPosted Nov 23, 2012, 12:46 AM
After days of trying this. You finally showed how to do it.You are a really talented fellow
Thx indeed
VulpesPosted Nov 22, 2012, 11:51 AM
Edward MunyaPosted Nov 22, 2012, 10:44 AM
I think the last challenge I have is to convert object values from the table
retrived by sqldatareader into a string array.
You have used a string array values to split firstname and lastname. I need to convert my values from a database to string array and pass them through the loop as you indicated.
Please any Idea?
Thx in advance.
Edward MunyaPosted Nov 22, 2012, 8:46 AM
I think of using a loop and extract all uppercase characters except
the last one. Make this part as Firstname and the remaining part of course shall be the lastname.
Any idea how to do this?
VulpesPosted Nov 22, 2012, 8:46 AM
The output is:
steve pottsPosted Nov 22, 2012, 8:35 AM
http://www.cheatography.com/davechild/cheat-sheets/regular-expressions/
Edward MunyaPosted Nov 22, 2012, 8:22 AM
It is working fine. Along the way I came across another issue where names are like in this format;
STEVEPotts
where all FirstName characters are in uppercase and only the first character of the last name is in uppercase.
How to split such text; I want FirstName STEVE Lastname Potts.
Thanks again
steve pottsPosted Nov 22, 2012, 8:09 AM
foreach (DataRow row in dt.Rows)
{
string rows = string.Format("{0} {1}", row.ItemArray[0], row.ItemArray[1])+ "\n";
textBox1.AppendText(rows.ToString());
}
connection.Close();
steve pottsPosted Nov 22, 2012, 7:57 AM
steve pottsPosted Nov 22, 2012, 7:51 AM
Edward MunyaPosted Nov 22, 2012, 7:11 AM
Seems to work fine with one values.
But one more thing. data to be split is a big table in sql. How to read it, split it into 2 columns and insert new values in another table with 2 columns i.e First name and LastName.
I am thinking of reading data by datareader to put these values in arrays and insert values in new table using sql command. But how???
rasul mohPosted Nov 22, 2012, 6:00 AM
TextBox1.Text.Split();
string fName = string.Empty;
string lName = string.Empty;
string[] words = TextBox1.Text.Split(' ');
if (words.Length >= 3)
{
fName = words[0];
lName = words[1];
}
else
{
fName = words[0];
}
TextBoxF.Text = fName.ToString();
TextBoxL.Text = lName.ToString();......
output display
TextBoxF.Text=Edward and TextBoxL.Text=John
and then write insert query from database , seperate column save the name
Easy method
steve pottsPosted Nov 22, 2012, 5:13 AM
steve pottsPosted Nov 22, 2012, 5:03 AM
VulpesPosted Nov 22, 2012, 4:57 AM