Files
Wino-Mail/Wino.Core/Extensions/StringExtensions.cs

22 lines
540 B
C#
Raw Normal View History

2024-04-18 01:44:37 +02:00
using System;
2025-02-16 11:54:23 +01:00
namespace Wino.Core.Extensions;
public static class StringExtensions
2024-04-18 01:44:37 +02:00
{
2025-02-16 11:54:23 +01:00
public static bool Contains(this string source, string toCheck, StringComparison comp)
2024-04-18 01:44:37 +02:00
{
2025-02-16 11:54:23 +01:00
return source?.IndexOf(toCheck, comp) >= 0;
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
public static string ReplaceFirst(this string text, string search, string replace)
{
int pos = text.IndexOf(search);
if (pos < 0)
2024-04-18 01:44:37 +02:00
{
2025-02-16 11:54:23 +01:00
return text;
2024-04-18 01:44:37 +02:00
}
2025-02-16 11:54:23 +01:00
return text.Substring(0, pos) + replace + text.Substring(pos + search.Length);
2024-04-18 01:44:37 +02:00
}
}