Untitled
unknown
csharp
a year ago
2.2 kB
5
Indexable
public static string GetStringBetweenTwoCharLast(string fullText, string fromText, string toText)
{
try
{
if (string.IsNullOrEmpty(fullText))
{
return "";
}
int pFrom = fullText.IndexOf(fromText) + fromText.Length;
int pTo = fullText.LastIndexOf(toText);
if (fullText.IndexOf(fromText) < 0 || pTo < 0)
{
return "";
}
return fullText.Substring(pFrom, pTo - pFrom);
}
catch (Exception ex)
{
return "";
}
}
public static string GetValueFromHeadersSendGrid(string fullText, string headerName)
{
if (!string.IsNullOrEmpty(fullText))
{
int pFrom = fullText.IndexOf(headerName) + headerName.Length;
if (fullText.IndexOf(headerName) < 0)
{
return "";
}
fullText = fullText.Substring(pFrom, fullText.Length - pFrom);
int pTo = fullText.IndexOf("\n");
if (pTo > 0)
{
return fullText.Substring(0, pTo);
}
}
return "";
}
public static string GetStringFromBeginToText(string fullText, string toText)
{
if (string.IsNullOrEmpty(fullText))
{
return "";
}
int pTo = fullText.LastIndexOf(toText);
if (pTo < 0)
{
return "";
}
return fullText.Substring(0, pTo);
}
public static string GetStringFromTextToLast(string fullText, string fromText)
{
if (string.IsNullOrEmpty(fullText))
{
return "";
}
int pTo = fullText.LastIndexOf(fromText);
if (pTo < 0)
{
return "";
}
return fullText.Substring(pTo + fromText.Length);
}
Editor is loading...
Leave a Comment