Click here to Skip to main content
15,914,014 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have a string as
Label1.Text="Name : Mohd Wasif";

I want only Mohd wasif

please help me.

Thanking you
Mohd Wasif
Posted
Updated 13-May-11 0:20am
v2

Try out this,

str1.substring(7);
 
Share this answer
 
v2
Just a note, in addition to existing answers: strings are immutable. No matter you do with strings, you never "remove", "add" or "modify" anything it a string. Instead, a brand-new string is created. It's important to know due to its performance and multithreading implications. For example, repeating "+" is very bad. A mutable version of string is System.Text.StringBuilder. Use it for performance, convert to string simply using System.Text.StringBuilder.ToString().

—SA
 
Share this answer
 
Comments
walterhevedeich 13-May-11 5:49am    
Good point.
Sergey Alexandrovich Kryukov 13-May-11 5:55am    
Well, just a side note... but thank you very much.
--SA
the best thing would be to split your string on a seperator ":"
string s = "Name : Mohd Wasif";
string[] words = s.Split( ':'); // split string on seperator

Label.Text = words[1].Trim( ); // assign trimmed value without leading or trailing spaces
 
Share this answer
 
Comments
anvas kuttan 13-May-11 6:24am    
my 5
u can use substring method for that..
search substring on net
 
Share this answer
 
Label1.Text.SubString(7);


or

Label1.Text.Replace("Name : ", Label1.Text);


Replace Label1.Text with the variable you have taken......Enjoy
 
Share this answer
 
v2
use regular expression

Regex.Match(input, @"^Name\s:\s(?<name>.+.?)", RegexOptions.IgnoreCase | RegexOptions.Compiled).Groups["name"].Value
</name>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900