Click here to Skip to main content
15,895,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys, i have here a string for example
Dim str as String
string = "CodeProject"

now i want a function that will cut the "Project" from the string leaving the string value "Code"

Any ideas on how to do this? Thanks




I dont have google :)
Posted
Updated 23-Jan-14 19:39pm
v2

You can use regular expression replace method. I am giving the sample in c#.

C#
using System.Text.RegularExpressions;


String str = "CodeProject"
Regex rgx = new Regex("Project");
      string result = rgx.Replace(str , " ");
 
Share this answer
 
v2
Comments
Goenitz 24-Jan-14 1:48am    
can you elaborate pattern? :)
ArunRajendra 24-Jan-14 1:49am    
Solution updated :)
You can use Sustring method,

C#
string cs = "CodeProject";

                var res = cs.Substring(4);

                Console.Write(res);
 
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