확장 메서드를 이용한 방법입니다
/// <summary>
/// 다중 스페이스 제거
/// "a b c d e" To "a b c d e"
/// </summary>
/// <param name="source"></param>
/// <returns></returns>
public static string RemoveMultipleSpace(this string source)
{
return string.IsNullOrWhiteSpace(source) ? "" : Regex.Replace(source, @"\s+", $"{(char)32}");
}
'c# > helper' 카테고리의 다른 글
| c# 공인 ip 가져오기 / c# public ip 가져오기 (0) | 2024.04.02 |
|---|---|
| c# 로컬 ip 가져오기 / c# local ip 가져오기 (0) | 2024.04.02 |
| c# 왼쪽부터 문자열 자르기 (0) | 2024.04.02 |
| c# IsNullOrWhiteSpace()을 이용한 trim() 안전하게 사용하기 (0) | 2024.04.02 |
| c# 마우스 드래그 창 옮기기 user32.DLL (0) | 2024.04.02 |