29 lines
704 B
C#
29 lines
704 B
C#
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];
|
|
}
|
|
}
|
|
}
|
|
|