Share via


Delete substring in string giving that substring

Question

Tuesday, August 8, 2006 6:51 AM

How can i delete a specific substring in a string in asp? Is there any method doing this? eg. I have the string "Hello World" and i want to cut the substring "lo Wo" so that i get back "Helrld"

Thank you

All replies (3)

Tuesday, August 8, 2006 7:18 AM ✅Answered

string _str_helloworld = "Hello World";

_str_helloworld.Remove(startindex,lenght)

This should do the trick.


Tuesday, August 8, 2006 7:19 AM ✅Answered | 1 vote

you can use method replace for that

something like could do

string hello = "Hello Word";
string result = hello.Replace("lo Wo","");

Hope this will help


Tuesday, August 8, 2006 7:20 AM ✅Answered

Perhaps you meant the specific text:

then you could use

_str_helloworld .Replace("ello w","");