using System.Text.RegularExpressions;
namespace Alchemy.Core.Services
{
public class RegexService
{
///
/// 判断正则表达式
///
///
///
///
public static bool IsMatch(string strRaw, string strFormat)
{
Regex regex = new Regex(strFormat, RegexOptions.None);
return regex.IsMatch(strRaw);
}
///
///
///
///
///
///
///
public static string GetStringBetween(string strInput, string strStart, string strEnd)
{
string pattern = Regex.Escape(strStart) + "(.*?)" + Regex.Escape(strEnd);
Match match = Regex.Match(strInput, pattern);
if (match.Success)
return match.Groups[1].Value;
return string.Empty;
}
}
}