Agent skill

JS Regex Cjk Word Boundary

by divinevideo in divinevideo/divine-mobile

Fix JavaScript regex failures when matching CJK (Chinese/Japanese/Korean) text using \b word boundaries.

MPL-2.0Auto-check passedDevelopment

Install JS Regex Cjk Word Boundary

skills CLI
$ npx skills add divinevideo/divine-mobile --skill js-regex-cjk-word-boundary -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install divinevideo/divine-mobile js-regex-cjk-word-boundary --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/divinevideo/divine-mobile.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/js-regex-cjk-word-boundary .claude/skills/js-regex-cjk-word-boundary && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
js-regex-cjk-word-boundary
GitHub stars
266
Token cost
~1.5k tokens
SKILL.md length
396 words
Files
1
Skills in repo
103
Repo updated
First seen
Licence
MPL-2.0

At a glance

Fix JavaScript regex failures when matching CJK (Chinese/Japanese/Korean) text using \b word boundaries.

  • Works in 3 steps: No error is thrown — the regex just… → The same pattern works perfectly for… → The CJK characters in the pattern are…
  • Regex pattern with \b silently fails to match Japanese
  • SKILL.md covers Problem, Context / Trigger Conditions, Root Cause and Solution, plus 4 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

JS Regex Cjk Word Boundary is an agent skill from divinevideo/divine-mobile. Fix JavaScript regex failures when matching CJK (Chinese/Japanese/Korean) text using \b word boundaries. Use when: (1) Regex pattern with \b silently fails to match Japanese, Chinese, or Korean text, (2) Pattern works for Latin/ASCII text but not CJK, (3) hasDriverLicenceCue or similar text-detection function returns false for CJK input despite correct characters, (4) inferIssuerFromTitleText or pattern-matching functions fail on non-Latin scripts. Root cause: JavaScript \b only recognizes [a-zA-Z0-9] as "word…

Its SKILL.md is about 1.5k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Development, covering Root cause analysis. It works with JavaScript. The licence is MPL-2.0.

When your agent uses it

  • Regex pattern with \b silently fails to match Japanese
  • Pattern works for Latin/ASCII text but not CJK
  • HasDriverLicenceCue
  • Similar text-detection function returns false for CJK input despite correct characters

Example prompts

  • “word characters”
  • “/js-regex-cjk-word-boundary”

Workflow steps

3 steps, taken from the first numbered list in SKILL.md.

  1. No error is thrown — the regex just returns false
  2. The same pattern works perfectly for Latin/ASCII text
  3. The CJK characters in the pattern are correct (verified by direct string comparison)

What it can do on your machine

Read from SKILL.md and the folder at commit c3d6f7e. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are javascript).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • developer.mozilla.org
    • github.com
    • breakthebit.org
    • npmjs.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

JS Regex Cjk Word Boundary loads about 1.5k tokens when it runs. Until then it costs about 172 tokens; SKILL.md has 396 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~172
When it runs · the whole SKILL.md, loaded when a task matches
~1.5k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from divinevideo/divine-mobile at commit c3d6f7e, republished under its MPL-2.0 licence (© divinevideo). 396 words, ~1,499 tokens.

Download SKILL.mdSave it as .claude/skills/js-regex-cjk-word-boundary/SKILL.md (or your agent's skills folder).
name
js-regex-cjk-word-boundary
description
Fix JavaScript regex failures when matching CJK (Chinese/Japanese/Korean) text using \b word boundaries. Use when: (1) Regex pattern with \b silently fails to match Japanese, Chinese, or Korean text, (2) Pattern works for Latin/ASCII text but not CJK, (3) hasDriverLicenceCue or similar text-detection function returns false for CJK input despite correct characters, (4) inferIssuerFromTitleText or pattern-matching functions fail on non-Latin scripts. Root cause: JavaScript \b only recognizes [a-zA-Z0-9_] as "word characters" — CJK characters are classified as \W (non-word), so \b before/after CJK always sees a non-word/non-word boundary and fails to match.
author
Claude Code
version
1.0.0
date
2026-03-09

JavaScript Regex: \b Word Boundary Fails with CJK Characters

Problem

JavaScript's \b (word boundary) assertion silently fails when used with CJK (Chinese/Japanese/Korean) characters. The regex compiles without error and runs without throwing, but it simply never matches CJK text that should match. This is particularly insidious because:

  1. No error is thrown — the regex just returns false
  2. The same pattern works perfectly for Latin/ASCII text
  3. The CJK characters in the pattern are correct (verified by direct string comparison)

Context / Trigger Conditions

  • Regex pattern like /\b\u904B\u8EE2\u514D\u8A31\u8A3C\b/ (Japanese: 運転免許証) returns false on text containing the exact characters
  • Pattern like /\b\uC6B4\uC804\uBA74\uD5C8\uC99D\b/ (Korean: 운전면허증) fails similarly
  • Text-detection functions (e.g., hasDriverLicenceCue(), inferIssuerFromTitleText()) return incorrect results for CJK input while working correctly for all Latin-script patterns
  • Any regex using \b boundaries around non-ASCII Unicode characters (also affects Cyrillic, Arabic, Thai, etc.)

Root Cause

JavaScript's \b matches the boundary between a "word character" (\w = [a-zA-Z0-9_]) and a "non-word character" (\W). CJK characters are classified as \W (non-word characters).

When \b appears before a CJK character, it looks for a \w-to-\W or \W-to-\w transition. But if the preceding character is also \W (whitespace, punctuation, start of string, or another CJK character), the boundary condition is \W-to-\W, which \b does NOT match.

javascript
// This FAILS — \b doesn't work with CJK
/\b\u904B\u8EE2\u514D\u8A31\u8A3C\b/.test("運転免許証")  // false!

// This WORKS — no word boundaries
/\u904B\u8EE2\u514D\u8A31\u8A3C/.test("運転免許証")  // true

Solution

Quick Fix: Remove \b from CJK patterns

Simply remove \b assertions from any regex pattern that matches CJK characters:

javascript
// Before (broken):
[/\b\u904B\u8EE2\u514D\u8A31\u8A3C\b/, "JAPAN"],      // 運転免許証
[/\b\uC6B4\uC804\uBA74\uD5C8\uC99D\b/, "KOREA"],      // 운전면허증

// After (working):
[/\u904B\u8EE2\u514D\u8A31\u8A3C/, "JAPAN"],            // 運転免許証
[/\uC6B4\uC804\uBA74\uD5C8\uC99D/, "KOREA"],           // 운전면허증
Better Fix: Use Unicode-aware boundaries (if available)

For environments supporting the v flag (ES2024+), you can use Unicode property escapes:

javascript
// Unicode-aware approach (requires /v flag support):
/(?<=^|[\s\p{P}])\u904B\u8EE2\u514D\u8A31\u8A3C(?=$|[\s\p{P}])/v
Show full SKILL.md (151 more words)Show less
Alternative: Manual boundary with lookbehind/lookahead
javascript
// Manual boundary that works with CJK:
/(?<!\p{L})\u904B\u8EE2\u514D\u8A31\u8A3C(?!\p{L})/u
For mixed Latin/CJK pattern arrays

When you have an array of patterns where some are Latin and some are CJK, use \b only for Latin patterns:

javascript
const patterns = [
  [/\bDRIVER'?S?\s+LICEN[CS]E\b/, "match"],   // Latin — \b works
  [/\bFÜHRERSCHEIN\b/, "match"],               // Latin+diacritics — \b works (Ü is \W but context helps)
  [/\u904B\u8EE2\u514D\u8A31\u8A3C/, "match"], // CJK — no \b needed
  [/\uC6B4\uC804\uBA74\uD5C8\uC99D/, "match"], // CJK — no \b needed
];

Verification

javascript
// Test that CJK matching works:
console.log(/\u904B\u8EE2\u514D\u8A31\u8A3C/.test("運転免許証"));  // true
console.log(/\uC6B4\uC804\uBA74\uD5C8\uC99D/.test("운전면허증"));  // true

// Verify it doesn't false-match substrings you don't want:
console.log(/\u904B\u8EE2\u514D\u8A31\u8A3C/.test("別の運転免許証テスト"));  // true (substring match is usually fine for CJK)

Example

Real-world case from a document-type detection function:

javascript
function hasDriverLicenceCue(text) {
  const combined = text.toUpperCase();
  return (
    /\bDRIVER'?S?\s+LICEN[CS]E\b/.test(combined) ||   // English
    /\bFÜHRERSCHEIN\b/.test(combined) ||               // German
    /\bPERMIS DE CONDUIRE\b/.test(combined) ||          // French
    /\u904B\u8EE2\u514D\u8A31\u8A3C/.test(combined) || // Japanese (no \b!)
    /\uC6B4\uC804\uBA74\uD5C8\uC99D/.test(combined)    // Korean (no \b!)
  );
}

Notes

  • This affects ALL non-ASCII Unicode scripts, not just CJK: Cyrillic, Arabic, Thai, Devanagari, etc.
  • The u (unicode) flag does NOT fix this — \b behavior with \w/\W is unchanged.
  • Removing \b from CJK patterns is generally safe because CJK characters are unlikely to appear as substrings within other words in unrelated contexts.
  • The regexp-cjk npm package provides CJK-aware regex utilities if you need more sophisticated matching.
  • When debugging: if a regex works for "DRIVER'S LICENCE" but not "運転免許証", suspect \b first.

References

© divinevideo, MPL-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/js-regex-cjk-word-boundary of divinevideo/divine-mobile.

Open the folder on GitHubat commit c3d6f7e

Compare with similar skills

JS Regex Cjk Word Boundary next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

JS Regex Cjk Word Boundary compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
JS Regex Cjk Word Boundary this skilldivinevideo/divine-mobile266—~1.5kAutomated safety check: PassMPL-2.0
CodeScope Codebase Graph AnalysisQwenLM/qwen-code28k1 repos~9.3kAutomated safety check: PassApache-2.0
Bug DetectiveGalaxy-Dawn/claude-scholar5.7k1 repos~2.1kAutomated safety check: PassMIT
Codegraph QAQwenLM/qwen-code-examples143—~4.3kAutomated safety check: PassNone
Code Review ChecklistshareAI-lab/learn-claude-code78k4 repos~1.1kAutomated safety check: PassMIT
@pierre/diffs Code Renderingpierrecomputer/pierre6.3k2 repos~803Automated safety check: PassApache-2.0

Similar skills

  • Answers questions about code structure, history, bugs and PR risk using a CodeScope knowledge graph and semantic index built from the repository.

    28k GitHub starsUsed in 1 repo~9.3k tokens
    DevelopmentAuto-check passed
  • Bug Detective

    Galaxy-Dawn/claude-scholar

    Applies a systematic debugging workflow to errors, exceptions and failures, with error-type tables, localization techniques and reference notes for Python, JavaScript and shell.

    5.7k GitHub starsUsed in 1 repo~2.1k tokens
    DevelopmentAuto-check passed
  • Codegraph QA

    QwenLM/qwen-code-examples

    Use CodeScope to analyze any indexed codebase via its graph database (neug) and vector index (zvec).

    143 GitHub stars~4.3k tokensUpdated 4 mo ago
    DevelopmentAuto-check passed
  • Code Review Checklist

    shareAI-lab/learn-claude-code

    Reviews code against a five-part checklist covering security, correctness, performance, maintainability and testing, and reports findings in a fixed format.

    78k GitHub starsUsed in 4 repos~1.1k tokens
    DevelopmentAuto-check passed
  • @pierre/diffs Code Rendering

    pierrecomputer/pierre

    Guides an agent through using @pierre/diffs to render syntax-highlighted files and diffs, and to build editing and review surfaces in React or plain JavaScript.

    6.3k GitHub starsUsed in 2 repos~803 tokens
    DevelopmentAuto-check passed
  • Installs, updates or migrates the vendored anti-slop Oxlint plugin in a repository, keeping local rule changes and the plugin's license and provenance files.

    5.4k GitHub stars~2.2k tokensUpdated 1 mo ago
    DevelopmentAuto-check passed

More from divinevideo/divine-mobile

All 103 skills in this repo
  • Fix ArgoCD ExternalSecret deployment failing with "namespace X is not permitted in project Y".

    266 GitHub stars~931 tokensUpdated today
    Auto-check passed
  • Art Direct

    divinevideo/divine-mobile

    Art direction for any content — reads text, PDF, Word, HTML, PPT, then proposes 2-3 creative directions with photography style, mood, and visual language.

    266 GitHub stars~4.8k tokensUpdated today
    Auto-check passed
  • Async Await Null Race Condition

    divinevideo/divine-mobile

    Fix "Null check operator used on a null value" errors when an object is set to null during an async await.

    266 GitHub stars~881 tokensUpdated today
    Auto-check passed
  • AWS V4 Signing Custom Headers Gcs

    divinevideo/divine-mobile

    Add custom metadata headers (x-amz-meta-) to AWS v4 signed requests for GCS S3-compatible API.

    266 GitHub stars~1k tokensUpdated today
    Auto-check passed
  • Bash Herestring Newline Secrets

    divinevideo/divine-mobile

    Fix password/secret authentication failures caused by trailing newlines when creating Google Cloud secrets (or similar) with bash here-strings.

    266 GitHub stars~791 tokensUpdated today
    Auto-check passed
  • Fix silent video/media processing failures caused by URL extraction code that filters on file extensions (.mp4, .webm, .webp).

    266 GitHub stars~1.1k tokensUpdated today
    Auto-check passed

Works with

Categories

Questions about JS Regex Cjk Word Boundary

What does JS Regex Cjk Word Boundary do?

Fix JavaScript regex failures when matching CJK (Chinese/Japanese/Korean) text using \b word boundaries. JS Regex Cjk Word Boundary is an agent skill from divinevideo/divine-mobile. Fix JavaScript regex failures when matching CJK (Chinese/Japanese/Korean) text using \b word boundaries.

When should I use JS Regex Cjk Word Boundary?

JS Regex Cjk Word Boundary fits situations like: regex pattern with \b silently fails to match Japanese; pattern works for Latin/ASCII text but not CJK; hasDriverLicenceCue; similar text-detection function returns false for CJK input despite correct characters.

How do I install JS Regex Cjk Word Boundary in Claude Code?

Run `npx skills add divinevideo/divine-mobile --skill js-regex-cjk-word-boundary -a claude-code`. Or copy the skill folder (.agents/skills/js-regex-cjk-word-boundary in divinevideo/divine-mobile) into .claude/skills/js-regex-cjk-word-boundary in your project. Claude Code loads it when a task matches its description.

How do I install JS Regex Cjk Word Boundary in Codex?

Run `npx skills add divinevideo/divine-mobile --skill js-regex-cjk-word-boundary -a codex`. Or copy the skill folder (.agents/skills/js-regex-cjk-word-boundary in divinevideo/divine-mobile) into .agents/skills/js-regex-cjk-word-boundary in your project. Codex loads it when a task matches its description.

Can I use JS Regex Cjk Word Boundary in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add divinevideo/divine-mobile --skill js-regex-cjk-word-boundary -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/js-regex-cjk-word-boundary, .gemini/skills/js-regex-cjk-word-boundary, .github/skills/js-regex-cjk-word-boundary and .opencode/skills/js-regex-cjk-word-boundary in your project.

What does JS Regex Cjk Word Boundary need to run?

SKILL.md names no scripts, command-line tools or credentials: JS Regex Cjk Word Boundary is instructions for the agent only.

Does JS Regex Cjk Word Boundary access the network?

SKILL.md names 4 domains. As links in the text: developer.mozilla.org, github.com, breakthebit.org and npmjs.com. This is read from the text; nothing was executed.

Is JS Regex Cjk Word Boundary safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does JS Regex Cjk Word Boundary use?

JS Regex Cjk Word Boundary is published under the MPL-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does JS Regex Cjk Word Boundary use?

About 1.5k tokens (SKILL.md is roughly 6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to JS Regex Cjk Word Boundary?

Skills that share tags, products or a category with JS Regex Cjk Word Boundary: CodeScope Codebase Graph Analysis (QwenLM/qwen-code, 28k stars), Bug Detective (Galaxy-Dawn/claude-scholar, 5.7k stars), Codegraph QA (QwenLM/qwen-code-examples, 143 stars) and Code Review Checklist (shareAI-lab/learn-claude-code, 78k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains JS Regex Cjk Word Boundary?

divinevideo (a GitHub organization) maintains it in divinevideo/divine-mobile, which has 266 GitHub stars. The repository holds 103 skills in this directory. The repository was last updated on October 10, 2026.

Source: divinevideo/divine-mobile on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.