How to remove all spaces from a string using Regex in C#

1 Answer

0 votes
using System;
using System.Text.RegularExpressions;

class Program
{
    static void Main() {
        String str = "Remove all spaces from string in C#";

	    str = Regex.Replace(str, @"\s+", "");

        Console.Write(str);
    }
}




/*
run:

RemoveallspacesfromstringinC#

*/

 



answered Nov 10, 2022 by avibootz

Related questions

1 answer 159 views
1 answer 107 views
1 answer 119 views
1 answer 125 views
125 views asked Nov 10, 2022 by avibootz
...