Add verifiable examples, PCRE2 runner, and GitHub Actions - #4
Merged
Merged
Conversation
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>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 4: make the cheat sheet’s ✓ / ✗ examples automatically checkable without turning the repo into an app.
Flavor choice
CI uses Python 3 + the
pcre2package (bundled libpcre2) onubuntu-latest, not Python’s stdlibreand not JavaScriptRegExp.pcre2can run the documented named-group form(?<Word>…)+\k<Word>, inline(?i), and(?#…).\w/\d/\bmatch the README’s PCRE default (no Han in\w).PyPI
regexwas 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.ymlhas 51 cases drawn from the README cookbook and core sections:first/all, flags, email / CN mobile / date / URL-ish / integers-decimals)skip: true):redos-nested-plus-doc-only—^(a+)+$documented only, not timed in CIlookaround-var-lookbehind-html— unbounded capturing lookbehind; the alternative<(\w+)>(.*?)</\1>is executedLocal run on this agent:
passed: 49 skipped: 2 failed: 0.How to run
Details and the flavor caveat: README section 如何运行校验. LICENSE is unchanged.