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 152 views
1 answer 101 views
1 answer 113 views
1 answer 114 views
114 views asked Nov 10, 2022 by avibootz
...