Write a String manipulation program [Answered]

I have two strings. One of them contains completely the entire other string. While that other string does not contain all of the first one. How do I write a program that deletes the entire chunk of the first string that the second string contains? Pic related is an example of how the strings functions.
8 Replies
Up
Up2y ago
I just answered you in #help-0 but just in case:
BlasterBlaster
I'm not sure this is correct $code
MODiX
MODiX2y ago
To post C# code type the following: ```cs // code here ``` Get an example by typing $codegif in chat If your code is too long, post it to: https://paste.mod.gg/
BlasterBlaster
string string1 = "The quick brown fox jumps over the lazy dog"
string string2 = "lazy dog"
string string1 = "The quick brown fox jumps over the lazy dog"
string string2 = "lazy dog"
So that returns the string "The quick brown fox jumps over the" @UpcraftLP
Up
Up2y ago
not exactly, but how about you try it ;)
Anar
Anar2y ago
You also gotta trim the space at the end.
BlasterBlaster
string string1 = "The quick brown fox jumps over the lazy dog";
string string2 = "lazy dog";
string string3 = string1.Replace(string2, string.Empty);
Console.WriteLine(string1);
Console.WriteLine(string2);
Console.WriteLine(string3);
Console.ReadLine();
string string1 = "The quick brown fox jumps over the lazy dog";
string string2 = "lazy dog";
string string3 = string1.Replace(string2, string.Empty);
Console.WriteLine(string1);
Console.WriteLine(string2);
Console.WriteLine(string3);
Console.ReadLine();
I think it works thanks.
Accord
Accord2y ago
✅ This post has been marked as answered!