Skip to content

Add verifiable examples, PCRE2 runner, and GitHub Actions - #4

Merged
cursor[bot] merged 2 commits into
masterfrom
cursor/examples-ci-phase4-37fc
Sep 15, 2026
Merged

cursor[bot] merged 2 commits into
masterfrom
cursor/examples-ci-phase4-37fc

Conversation

@xuzongbao

Copy link
Copy Markdown
Owner

Phase 4: make the cheat sheet’s ✓ / ✗ examples automatically checkable without turning the repo into an app.

Flavor choice

CI uses Python 3 + the pcre2 package (bundled libpcre2) on ubuntu-latest, not Python’s stdlib re and not JavaScript RegExp.

  • The notes are PCRE-first; pcre2 can run the documented named-group form (?<Word>…) + \k<Word>, inline (?i), and (?#…).
  • The checker compiles with ASCII by default so \w / \d / \b match the README’s PCRE default (no Han in \w).
  • This is still not a full clone of regex101’s PCRE2 UI (unbounded capturing lookbehind is skipped; see below).

PyPI regex was considered (option B) but it rejects \k<name>. JS / RE2 cannot honestly execute the PCRE teaching cases (backreferences, named \k, comments). Perl is on the runner images but would need extra YAML modules.

Cases

examples.yml has 51 cases drawn from the README cookbook and core sections:

  • 49 executed (metacharacters, quantifiers, character classes, alternation, groups / IPv4, negation, backreferences, lookaround, greedy vs lazy first/all, flags, email / CN mobile / date / URL-ish / integers-decimals)
  • 2 skipped (skip: true):
    • redos-nested-plus-doc-only^(a+)+$ documented only, not timed in CI
    • lookaround-var-lookbehind-html — unbounded capturing lookbehind; the alternative <(\w+)>(.*?)</\1> is executed

Local run on this agent: passed: 49 skipped: 2 failed: 0.

How to run

python3 -m pip install -r requirements-ci.txt
python3 scripts/check_examples.py

Details and the flavor caveat: README section 如何运行校验. LICENSE is unchanged.

Open in Web Open in Cursor 

cursoragent and others added 2 commits September 15, 2026 10:46
Phase 4 keeps the repo documentation-first: teaching cases from the
README cookbook and core sections are listed in examples.yml and checked
with the pcre2 Python package (real PCRE2, ASCII \w default). ReDoS and
unbounded capturing lookbehind are documented but skipped in CI.

Co-authored-by: Elven_xu <799835984@qq.com>
Avoid the Node.js 20 deprecation warning on ubuntu-latest.

Co-authored-by: Elven_xu <799835984@qq.com>
@xuzongbao
xuzongbao marked this pull request as ready for review September 15, 2026 10:47
@cursor
cursor Bot merged commit c81ed5e into master Sep 15, 2026
1 check passed
@cursor
cursor Bot deleted the cursor/examples-ci-phase4-37fc branch September 15, 2026 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants