zh-regex-helper

zh-regex-helper is a skill for Claude Code, Codex from guyulong/cn-agent-skills. It costs 15 tokens per session (1,386 once invoked), scanned A, original, MIT.

A reference guide of regular expressions for matching Chinese text and common formats. Regular expressions are text patterns used to find or validate strings.

In plain words
What is it for?
Use it when matching Chinese characters, mainland Chinese phone numbers, identity-card formats, email addresses, Chinese punctuation, or URLs.
Why use it?
It provides ready-made patterns while explaining limitations, such as incomplete Chinese-character ranges and checks that validate only an ID's format, not whether its details are real.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when matching Chinese characters, mainland Chinese phone numbers, identity-card formats, email addresses, Chinese punctuation, or URLs.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/guyulong/cn-agent-skills/zh-regex-helper
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add guyulong/cn-agent-skills --skill zh-regex-helper
Clone the repo
git clone --depth 1 https://github.com/guyulong/cn-agent-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for zh-regex-helper

README.md
[![agentmods](https://agentmods.dev/badge/skills/guyulong/cn-agent-skills/zh-regex-helper/github.svg)](https://agentmods.dev/skills/guyulong/cn-agent-skills/zh-regex-helper)
Your own site
<a href="https://agentmods.dev/skills/guyulong/cn-agent-skills/zh-regex-helper"><img src="https://agentmods.dev/badge/skills/guyulong/cn-agent-skills/zh-regex-helper/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for zh-regex-helper

Your own site · 80×15
<a href="https://agentmods.dev/skills/guyulong/cn-agent-skills/zh-regex-helper"><img src="https://agentmods.dev/badge/skills/guyulong/cn-agent-skills/zh-regex-helper.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 15 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,386 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00015 $0.01386
Opus 5 $0.00008 $0.00693
Sonnet 5 $0.00003 $0.00277
Haiku 4.5 $0.00002 $0.00139

Measured 11d ago against content hash fac9d1d33d08, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

zh-regex-helper scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 11d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/zh-regex-helper/SKILL.md · 125 lines

What it actually says

中文正则表达式助手

使用场景

处理中文文本时常用的正则表达式。

重要说明

\u4e00-\u9fa5 不是完整汉字范围。 它只覆盖 CJK 基本区(20,902 字),不含 CJK 扩展 A~I 区的汉字(如 𠀀 等)。如需匹配更完整的汉字范围:

  • Unicode 属性(推荐)\p{Han}(需引擎支持,如 Python regex 模块、JavaScript ES2018+)
  • 宽范围[\u4e00-\u9fff\u3400-\u4dbf\U00020000-\U0002a6df]

本文档中的 \u4e00-\u9fa5 适用于大多数日常场景,但请注意其局限性。

常用正则

1. 中文字符

[\u4e00-\u9fa5]           # 单个中文字符(CJK 基本区)
[\u4e00-\u9fa5]+          # 一个或多个
^[\u4e00-\u9fa5]{2,10}$   # 2-10 个中文字符(姓名等)
\p{Han}                   # 完整汉字(需引擎支持)

2. 手机号

^1[3-9]\d{9}$             # 中国大陆手机号
^(\+86)?1[3-9]\d{9}$      # 带国际区号

3. 身份证号(仅格式校验)

^[1-9]\d{5}(19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dXx]$

局限性: 此正则只校验以下格式:

  • 6 位地区编码(不验证是否为合法行政区划)
  • 8 位出生日期(不验证该日期是否真实存在,如 2月30日也能通过)
  • 3 位顺序码 + 1 位校验码(不验证校验位是否正确)

如需完整校验,需要额外验证:

  1. 校验码(ISO 7064:1983, MOD 11-2 算法)
  2. 地区编码是否在民政部公布的行政区划代码中
  3. 出生日期是否真实有效

正则只适合做前端初步过滤,不能替代后端完整校验。

4. 邮箱

^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$

5. 中文标点

[\u3002\uff1b\uff0c\uff1a\u201c\u201d\uff08\uff09\u3001\uff1f\u300a\u300b]
# 。;,:""()、?《》

6. URL

https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)

7. IP 地址

^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$

8. 中文 + 英文混合

^[\u4e00-\u9fa5a-zA-Z0-9]+$   # 中文、英文、数字

9. 提取中文

import re
text = "Hello 你好 World 世界"
chinese = re.findall(r'[\u4e00-\u9fa5]+', text)
# 结果: ['你好', '世界']

10. 去除 HTML 标签

import re
html = '<p>你好<span>世界</span></p>'
text = re.sub(r'<[^>]+>', '', html)
# 结果: '你好世界'

Python 示例

import re

def is_valid_phone(phone: str) -> bool:
    """验证手机号(仅格式校验)"""
    return bool(re.match(r'^1[3-9]\d{9}$', phone))

def is_valid_id_card_format(id_card: str) -> bool:
    """验证身份证号格式(仅格式,不校验校验位和真实性)"""
    pattern = r'^[1-9]\d{5}(19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dXx]$'
    return bool(re.match(pattern, id_card))

def extract_chinese(text: str) -> list:
    """提取中文文本(CJK 基本区)"""
    return re.findall(r'[\u4e00-\u9fa5]+', text)

def mask_phone(phone: str) -> str:
    """手机号脱敏: 138****8000"""
    return re.sub(r'(\d{3})\d{4}(\d{4})', r'\1****\2', phone)

def mask_id_card(id_card: str) -> str:
    """身份证脱敏: 110***********1234"""
    return re.sub(r'(\d{3})\d{11}(\d{4})', r'\1***********\2', id_card)
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 11d ago First seen · 125 lines · 15 tokens per session scan A fac9d1d33d08

Subscribe to this mod's changes

zh-regex-helper is a skill published in the GitHub repository guyulong/cn-agent-skills (3 stars, last pushed 3mo ago), licensed MIT. It adds 15 tokens to every session and 1,386 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

Python 数据分析

A set of instructions for using Python, a programming language, and pandas, a library for working with tables of data. It covers analysing files, calculating statistics, grouping data and making charts.

Changan-Su/Forsion · 37 tokens

python-idioms

A set of guidelines for writing clear, safe, maintainable Python. It covers common language features, type annotations, standard-library choices, function design, exceptions, and resource handling.

Wade-DevCode/awesome-coding-skills-cn · 21 tokens

lc_python_repl

A Python read-evaluate-print loop, or REPL, where code can be run interactively. Python is a programming language often used for data work and automation.

sunchaokun/zensers · 12 tokens

Python скрипт для очистки CSV и подготовки к импорту в PostgreSQL

A Python script for cleaning CSV files before importing them into PostgreSQL, a database system. It handles Russian Windows-style text encoding, percentage values, data types, dates, and code lists.

ECNU-ICALK/AutoSkill · 96 tokens

Написание простых алгоритмов на Python

A guide for writing simple Python programs with loops, strings, and short variable names. Python is a programming language commonly used for scripts and beginner exercises.

ECNU-ICALK/AutoSkill · 44 tokens

python-refactoring

A Python refactoring guide for finding code smells, improving readability, and applying suitable design patterns. Refactoring means changing code structure without changing what the code is meant to do.

Ascend/agent-skills · 142 tokens