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
Up3y ago
I just answered you in #help-0 but just in case:
BlasterBlaster
BlasterBlasterOP3y ago
I'm not sure this is correct $code
MODiX
MODiX3y 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
BlasterBlasterOP3y ago
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
Up3y ago
not exactly, but how about you try it ;)
Anar
Anar3y ago
You also gotta trim the space at the end.
BlasterBlaster
BlasterBlasterOP3y ago
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
Accord3y ago
✅ This post has been marked as answered!
Want results from more Discord servers?
Add your server