Skip to content

Instantly share code, notes, and snippets.

@neon-izm
Created February 24, 2019 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neon-izm/32831110c592f31e6402ed3a6745b845 to your computer and use it in GitHub Desktop.
Save neon-izm/32831110c592f31e6402ed3a6745b845 to your computer and use it in GitHub Desktop.
日本語パスを判定したい時に使う
using System.Text.RegularExpressions;
using System;
public class PathChecker{
static bool IsContainHiragana(string str)
{
return Regex.IsMatch(str, @"[\p{IsHiragana}]");
}
static bool IsContainKatakana(string str)
{
return Regex.IsMatch(str, @"[\p{IsKatakana}]");
}
static bool IsContainKanji(string str)
{
return Regex.IsMatch(str, @"[\p{IsCJKUnifiedIdeographs}" +
@"\p{IsCJKCompatibilityIdeographs}" +
@"\p{IsCJKUnifiedIdeographsExtensionA}]|" +
@"[\uD840-\uD869][\uDC00-\uDFFF]|\uD869[\uDC00-\uDEDF]");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment