2012-05-28 22:01:03 +00:00
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
|
|
|
|
|
|
2012-05-17 03:04:03 +00:00
|
|
|
|
namespace Axios.Engine.Extensions
|
2012-03-19 23:57:59 +00:00
|
|
|
|
{
|
|
|
|
|
public static class AxiosExtensions_String
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Get the string slice between the two indexes.
|
|
|
|
|
/// Inclusive for start index, exclusive for end index.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static string Slice(this string source, int start, int end)
|
|
|
|
|
{
|
|
|
|
|
if (end < 0) // Keep this for negative end support
|
|
|
|
|
{
|
|
|
|
|
end = source.Length + end;
|
|
|
|
|
}
|
|
|
|
|
int len = end - start; // Calculate length
|
|
|
|
|
return source.Substring(start, len); // Return Substring of length
|
|
|
|
|
}
|
2012-05-28 22:01:03 +00:00
|
|
|
|
|
|
|
|
|
public static bool IsNullOrWhiteSpace(this string str)
|
|
|
|
|
{
|
|
|
|
|
if (str == null || str == string.Empty)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
if (Regex.Match(str, "([:blank:])").Success)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2012-03-19 23:57:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|