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

I want to trim chars till ?? values
I have string like string values="suhel??78a";

I want string value2="suhel??"; I want to Trim values what ever afer ?? marks symbol can you guide or send snippets.
Posted
Comments

You can use, for example, regular expressions:
http://en.wikipedia.org/wiki/Regular_Expression[^],
https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex%28v=vs.110%29.aspx[^].

You can do the same by some combination of System.String members, for example, Length, IndexOf(String) and Substring(Int32), another way would be using Split(Char[], StringSplitOptions) or Split(String[], StringSplitOptions) with System.StringSplitOptions.RemoveEmptyEntries:
https://msdn.microsoft.com/en-us/library/system.string%28v=vs.110%29.aspx[^].

—SA
 
Share this answer
 
Comments
Peter Leow 31-Aug-15 10:53am    
This is more comprehensive. 5ed!
Sergey Alexandrovich Kryukov 31-Aug-15 10:59am    
Thank you, Peter.
—SA
Maciej Los 31-Aug-15 12:05pm    
5ed!
Sergey Alexandrovich Kryukov 31-Aug-15 12:31pm    
Thank you, Maciej.
—SA
First, use IndexOf[^] to locate the position of the ?? in the string, then use Substring[^] to extract the part that you want.
 
Share this answer
 
Comments
Maciej Los 31-Aug-15 12:06pm    
5ed! I suggested this in my comment to the question.
Peter Leow 31-Aug-15 21:15pm    
Thank you, Maciej.

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