+ 1

How can I improve this code ?

I'm trying to solve the symbols codecoach using c#, but when I use Regex it gives spaces. And it fails all the test cases.using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Text.RegularExpressions; namespace SoloLearn { class Program { static void Main(string[] args) { string input = Console.ReadLine(); string result = Regex.Replace(input, "[^a-zA-Z0-9_]+"," "); Console.WriteLine(result); } } }

22nd Apr 2020, 9:18 PM
Joseph Oritseweyinmi
Joseph Oritseweyinmi - avatar
2 ответов
+ 1
input.Trim() or result.Trim() depending on where you wanna elimnate the space
23rd Apr 2020, 6:50 AM
Abdoul Hakim
Abdoul Hakim - avatar
+ 1
string result =input.Replace(" ","");
23rd Apr 2020, 6:52 AM
Ayan Poddar
Ayan Poddar - avatar