Skip to content

Instantly share code, notes, and snippets.

View kururu-abdo's full-sized avatar
😍
Learning

kururu kururu-abdo

😍
Learning
View GitHub Profile
@karenpayneoregon
karenpayneoregon / Extensions.cs
Last active April 4, 2024 00:44
Working with strings and ternary operator
using System.Text.RegularExpressions;
public static class StringExtensions
{
// remove double spaces
public static string RemoveExtraSpaces(this string sender, bool trimEnd = false)
{
const RegexOptions options = RegexOptions.None;
var regex = new Regex("[ ]{2,}", options);
var result = regex.Replace(sender, " ");