Created
February 24, 2019 16:45
-
-
Save neon-izm/32831110c592f31e6402ed3a6745b845 to your computer and use it in GitHub Desktop.
日本語パスを判定したい時に使う
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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