Is Chinese Character
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace Kenly.ChineseSegment.Core
{
internal static class Utility
{
/// <summary>
///
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
public static bool IsValidFile(string filePath)
{
if (string.IsNullOrEmpty(filePath))
{
return false;
}
if (!System.IO.File.Exists(filePath))
{
return false;
}
return true;
}
/// <summary>
///
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
public static bool IsChinese(string text)
{
string regExpression = "[\u4e00-\u9fa5]";
return Regex.IsMatch(text, regExpression);
}
/// <summary>
///
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
public static bool IsLetter(string text)
{
string regExpression = "[a-z|A-Z]";
return Regex.IsMatch(text, regExpression);
}
/// <summary>
///
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
public static bool IsNumber(string text)
{
string regExpression = "[0-9]";
return Regex.IsMatch(text, regExpression);
}
}
}
Related examples in the same category