Regex Cheat Sheet
Practical Regex cheat sheet with setup steps, core workflows, debugging, and copy-paste examples.
regex syntax examples reference
Regex cheat sheet with real commands and snippets for setup, core workflows, debugging, and production-safe automation patterns. If you are working across tools, pair this with the PHP Cheat Sheet and Ruby Cheat Sheet.
Setup and Validation
Goal: Run formatters and linters for content files
# Format project files when formatter is available
npx prettier -w . || true
# Lint Markdown/YAML/JSON if linters exist
npx markdownlint-cli2 '**/*.md' || npx yaml-language-server --help || true
# Search for TODO placeholders before publish
rg "TODO|TBD" .
Core Patterns
Goal: Use a production-safe snippet
# Match semantic version strings like 1.2.3
^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z.-]+)?$
# Match ISO date (YYYY-MM-DD)
^(19|20)\d\d-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$
# Capture domain from URL
^https?:\/\/(?:www\.)?([^\/]+)
Automation and CI
Goal: Add validation step to CI pipeline
# Run strict shell mode in CI
set -euo pipefail
# Validate syntax and formatting in one pass
npx prettier -c .
# Fail build if broken references exist
rg "](/[^)]+)" src/content -n
Debugging and Troubleshooting
Goal: Track parse failures quickly
# Use ripgrep to isolate malformed syntax
rg "{{|}}|<[^>]*$" src -n
# Print files with potential encoding issues
file -I src/content/sheets/*.md
# Re-run formatter with explicit parser
npx prettier --parser markdown src/content/sheets/*.md || true
Common Gotchas
- Keep Regex content valid and machine-readable for build pipelines.
- Avoid trailing commas or comments in strict JSON files.
- Use consistent heading depth to keep TOC generation stable.
- Prefer explicit encoding (UTF-8) for portability.
- Run formatter checks before committing content edits.
Related Sheets
- PHP Cheat Sheet — daily PHP commands and production-ready examples.
- Ruby Cheat Sheet — daily Ruby commands and production-ready examples.
- Rust Cheat Sheet — daily Rust commands and production-ready examples.
Related Cheat Sheets
PHP Cheat Sheet
Practical PHP cheat sheet with setup steps, core workflows, debugging, and copy-paste examples.
Ruby Cheat Sheet
Practical Ruby cheat sheet with setup steps, core workflows, debugging, and copy-paste examples.
Rust Cheat Sheet
Practical Rust cheat sheet with setup steps, core workflows, debugging, and copy-paste examples.