You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为现有正则表达式添加韩文(Hangul)匹配范围?

Adding Hangul Support to Your Regex

Got it, let's get your regex updated to include Hangul characters!

First, the most common Hangul characters you'll want to match are Hangul Syllables—these are the full combined characters like 가, 나, 안녕—their Unicode range is U+AC00 to U+D7AF, which you can represent directly in regex as 가-힣 (C# supports Unicode characters in regex patterns when your file/string is properly encoded).

Updated Regex (Basic Hangul Support)

If you just need to match standard full Hangul syllables, modify your regex like this:

Regex.IsMatch(p.Name, @"^[a-zA-Z0-9ァ-ヾぁ-んー一-龠々가-힣]+$")

Full Hangul Support (Including Standalone Jamo)

If you also want to cover standalone Hangul Jamo (individual consonants/vowels like ㄱ, ㅏ, ㅑ), you'll need to add three additional Unicode ranges. These cover the building blocks of Hangul that aren't combined into full syllables:

  • Hangul Jamo: U+1100-U+11FF
  • Hangul Compatibility Jamo: U+3130-U+318F
  • Hangul Jamo Extended-A: U+A960-U+A97F

Here's the regex with complete Hangul coverage:

Regex.IsMatch(p.Name, @"^[a-zA-Z0-9ァ-ヾぁ-んー一-龠々가-힣\u1100-\u11FF\u3130-\u318F\uA960-\uA97F]+$")

Quick Testing Tip

To confirm it works as expected, test with sample strings:

  • Valid (returns true): "안녕하세요123ABC漢字カタカナ"
  • Invalid (returns false): "안녕!하세요" (contains an exclamation mark outside your allowed set)

内容的提问来源于stack exchange,提问作者Goon

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 06:57:32