sozsoft-platform/api/src/Sozsoft.Platform.Domain/Extensions/StringExtensions.cs

30 lines
704 B
C#
Raw Normal View History

2026-02-24 20:44:16 +00:00
using System;
namespace Sozsoft.Platform.Extensions
{
public static class StringExtensions
{
public static string RemoveParentheses(this string str)
{
return str?.Replace("(", "").Replace(")", "");
}
public static string GetSegment(this string str, char segment, int index)
{
var start = str.NthIndexOf(segment, index);
if (start == -1)
{
return null;
}
start += 1;
var end = str.NthIndexOf(segment, index + 1);
if (end == -1)
{
return null;
}
return str[start..end];
}
}
}