29 lines
805 B
C#
29 lines
805 B
C#
namespace EonaCat.Connections.Helpers
|
|
{
|
|
internal class StringHelper
|
|
{
|
|
public static string GetTextBetweenTags(string message, string startTag, string endTag)
|
|
{
|
|
int startIndex = message.IndexOf(startTag);
|
|
if (startIndex == -1)
|
|
{
|
|
return string.Empty;
|
|
}
|
|
|
|
int endIndex = message.IndexOf(endTag, startIndex + startTag.Length);
|
|
if (endIndex == -1)
|
|
{
|
|
return string.Empty;
|
|
}
|
|
|
|
int length = endIndex - startIndex - startTag.Length;
|
|
if (length < 0)
|
|
{
|
|
return string.Empty;
|
|
}
|
|
|
|
return message.Substring(startIndex + startTag.Length, length);
|
|
}
|
|
}
|
|
}
|