Click here to Skip to main content
15,893,161 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all,
str from = "\" raghu \" <a@gmail.com>";

i need to trim and I need only a@gmail.com
any one can help me ?????
Posted
Updated 25-Nov-13 21:17pm
v3
Comments
Karthik_Mahalingam 26-Nov-13 3:14am    
question not clear..

you can use Replace,Trim functions to remove unwanted characters from the string..
Sergey Alexandrovich Kryukov 26-Nov-13 3:17am    
You are right, Trim is not very useful here, But not Replace (what is that, inertia of thinking? many do this pointless suggestion, probably without understanding that strings are immutable), but Substring, or, better, Regex. Please see my answer.
—SA
Sergey Alexandrovich Kryukov 26-Nov-13 3:15am    
Not a question. "any one can help me?" does not count, as the answer ("yes, someone can") is not what you want.
—SA

What's the problem? Trim functions is fully described: http://msdn.microsoft.com/en-us/library/system.string%28v=vs.110%29.aspx[^].

However, you don't really need Trim. What you do depends on the set of possible input strings and your requirements to the extraction of data. Showing a single example does not mean specification. You can either use String.Substring or Regular Expressions:
http://en.wikipedia.org/wiki/Regular_expression[^],
http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex%28v=vs.110%29.aspx[^].

I'll leave the implementation, which should be quite trivial, for your home exercise.

—SA
 
Share this answer
 
this might help you i guess..


C#
str = str.Substring(str.IndexOf('<')+1).Trim().TrimEnd('>');
 
Share this answer
 
C#
string from = "\" raghu \" <a@gmail.com>";
 string[] stringTemp1=from.Split('<');
 string _from = stringTemp1[1].ToString();
 string[] stringTemp2 = _from.Split('>');
 _from = stringTemp2[0].ToString();
 
Share this answer
 
v2

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