Skill: bytesagain-lab/regexr (version 2.0.0)

--- name: Regexr description: "Create, test, and learn regular expressions with live matching. Use when validating patterns, checking groups, generating regex, linting syntax." version: "2.0.0" author: "BytesAgain" homepage: https://bytesagain.com source: https://github.com/bytesagain/ai-skills tags: ["regex", "regexp", "正则表达式", "pattern", "javascript", "utility", "developer"] categories: ["Developer Tools", "Utility"] commands: - name: "help" description: "显示RegExr工具的帮助信息和可用命令列表。" usage: "regexr help" - name: "run" description: "启动RegExr交互式界面，允许用户创建、测试和调试正则表达式。" usage: "regexr run" - name: "info" description: "提供RegExr工具的版本信息和相关资源链接。" usage: "regexr info" - name: "status" description: "检查RegExr工具的运行状态和依赖项健康状况。" usage: "regexr status" changelog: - version: "2.0.0" date: "2026-03-15" changes: - "初始版本发布" pricing_model: "free" license: "MIT" docs_url: "https://bytesagain.com/skills/regexr" support_url: "https://bytesagain.com/feedback" --- # Regexr Developer tools CLI for checking, validating, generating, and working with regular expressions and code patterns. Lint syntax, explain complex expressions, convert between formats, generate templates, diff pattern versions, preview matches, fix common regex issues, and produce reports — all from the command line with persistent local logging. ## Commands Run `regexr <command> [args]` to use. | Command | Description | |---------|-------------| | `check` | Check regex patterns for correctness and common pitfalls | | `validate` | Validate regex syntax and structure | | `generate` | Generate regex patterns from descriptions or examples | | `format` | Format and prettify regex expressions | | `lint` | Lint regex for style, performance, and safety issues | | `explain` | Explain what a regex pattern does in plain language | | `convert` | Convert regex between flavors (PCRE, JS, Python, etc.) | | `template` | Apply or manage regex templates for common use cases | | `diff` | Diff two regex patterns and show behavioral differences | | `preview` | Preview regex matches against sample text | | `fix` | Auto-fix common regex issues (escaping, anchoring, etc.) | | `report` | Generate regex quality and coverage reports | | `stats` | Show summary statistics across all categories | | `export <fmt>` | Export data in json, csv, or txt format | | `search <term>` | Search across all logged entries | | `recent` | Show recent activity from history log | | `status` | Health check — version, data dir, disk usage | | `help` | Show help and available commands | | `version` | Show version (v2.0.0) | Each domain command (check, validate, generate, etc.) works in two modes: - **Without arguments**: displays the most recent 20 entries from that category - **With arguments**: logs the input with a timestamp and saves to the category log file ## Data Storage All data is stored locally in `~/.local/share/regexr/`: - Each command creates its own log file (e.g., `check.log`, `validate.log`, `generate.log`) - A unified `history.log` tracks all activity across commands - Entries are stored in `timestamp|value` pipe-delimited format - Export supports JSON, CSV, and plain text formats ## Requirements - Bash 4+ with `set -euo pipefail` strict mode - Standard Unix utilities: `date`, `wc`, `du`, `tail`, `grep`, `sed`, `cat` - No external dependencies or API keys required ## When to Use 1. **Building and testing regex patterns** — use `generate` to create patterns from descriptions, `check` to verify correctness, and `preview` to test against sample data 2. **Learning and understanding regex** — use `explain` to break down complex patterns into plain-language descriptions, perfect for code reviews or onboarding 3. **Linting and fixing regex in codebases** — run `lint` to catch performance and safety issues (catastrophic backtracking, unanchored patterns), then `fix` to auto-correct them 4. **Converting regex across languages** — use `convert` to translate patterns between JavaScript, Python, PCRE, and other flavors when porting code 5. **Documenting regex usage in projects** — log patterns with `template`, generate `report` summaries, and `export` data for documentation or audits ## Examples ```bash # Check a regex pattern for issues regexr check "^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z]{2,}$ — email validation" # Validate regex syntax regexr validate "(?<=@)[a-z]+\.com — lookbehind syntax OK" # Generate a pattern from description regexr generate "match IPv4 addresses: \d{1,3}(\.\d{1,3}){3}" # Explain a complex regex regexr explain "^(?=.*[A-Z])(?=.*\d).{8,}$ — password: 1 uppercase, 1 digit, 8+ chars" # Lint for performance issues regexr lint "(a+)+ — warning: catastrophic backtracking possible" # Convert between flavors regexr convert "JS→Python: /\d+/g becomes re.findall(r'\d+', text)" # Fix common issues regexr fix "added anchors: ^pattern$ and escaped special chars" # Preview matches regexr preview "pattern=[0-9]{3}-[0-9]{4} matched: 555-1234, 800-9999" # View summary statistics regexr stats # Export all data as JSON regexr export json # Search logged patterns regexr search "email" ``` ## Output All commands output to stdout. Redirect to a file if needed: ```bash regexr report "weekly pattern audit" > report.txt regexr export csv # saves to ~/.local/share/regexr/export.csv ``` ## Configuration Set `DATA_DIR` by modifying the script, or use the default: `~/.local/share/regexr/` --- Powered by BytesAgain | bytesagain.com | [REDACTED_SECRET]

path: scripts/script.sh
content: #!/usr/bin/env bash
# Regexr — devtools tool
# Powered by BytesAgain | bytesagain.com | [REDACTED_SECRET]
set -euo pipefail

DATA_DIR="${HOME}/.local/share/regexr"
mkdir -p "$DATA_DIR"

_log() { echo "$(date '+%m-%d %H:%M') $1: $2" >> "$DATA_DIR/history.log"; }
_version() { echo "regexr v2.0.0"; }

_help() {
    echo "Regexr v2.0.0 — devtools toolkit"
    echo ""
    echo "Usage: regexr <command> [args]"
    echo ""
    echo "Commands:"
    echo "  check              Check"
    echo "  validate           Validate"
    echo "  generate           Generate"
    echo "  format             Format"
    echo "  lint               Lint"
    echo "  explain            Explain"
    echo "  convert            Convert"
    echo "  template           Template"
    echo "  diff               Diff"
    echo "  preview            Preview"
    echo "  fix                Fix"
    echo "  report             Report"
    echo "  stats              Summary statistics"
    echo "  export <fmt>       Export (json|csv|txt)"
    echo "  search <term>      Search entries"
    echo "  recent             Recent activity"
    echo "  status             Health check"
    echo "  help               Show this help"
    echo "  version            Show version"
    echo ""
    echo "Data: $DATA_DIR"
}

_stats() {
    echo "=== Regexr Stats ==="
    local total=0
    for f in "$DATA_DIR"/*.log; do
        [ -f "$f" ] || continue
        local name=$(basename "$f" .log)
        local c=$(wc -l < "$f")
        total=$((total + c))
        echo "  $name: $c entries"
    done
    echo "  ---"
    echo "  Total: $total entries"
    echo "  Data size: $(du -sh "$DATA_DIR" 2>/dev/null | cut -f1)"
}

_export() {
    local fmt="${1:-json}"
    local out="$DATA_DIR/export.$fmt"
    case "$fmt" in
        json)
            echo "[" > "$out"
            local first=1
            for f in "$DATA_DIR"/*.log; do
                [ -f "$f" ] || continue
                local name=$(basename "$f" .log)
                while IFS='|' read -r ts val; do
                    [ $first -eq 1 ] && first=0 || echo "," >> "$out"
                    printf '  {"type":"%s","time":"%s","value":"%s"}' "$name" "$ts" "$val" >> "$out"
                done < "$f"
            done
            echo "\n]" >> "$out"
            ;;
        csv)
            echo "type,time,value" > "$out"
            for f in "$DATA_DIR"/*.log; do
                [ -f "$f" ] || continue
                local name=$(basename "$f" .log)
                while IFS='|' read -r ts val; do echo "$name,$ts,$val" >> "$out"; done < "$f"
            done
            ;;
        txt)
            echo "=== Regexr Export ===" > "$out"
            for f in "$DATA_DIR"/*.log; do
                [ -f "$f" ] || continue
                echo "--- $(basename "$f" .log) ---" >> "$out"
                cat "$f" >> "$out"
            done
            ;;
        *) echo "Formats: json, csv, txt"; return 1 ;;
    esac
    echo "Exported to $out ($(wc -c < "$out") bytes)"
}

_status() {
    echo "=== Regexr Status ==="
    echo "  Version: v2.0.0"
    echo "  Data dir: $DATA_DIR"
    echo "  Entries: $(cat "$DATA_DIR"/*.log 2>/dev/null | wc -l) total"
    echo "  Disk: $(du -sh "$DATA_DIR" 2>/dev/null | cut -f1)"
    echo "  Last: $(tail -1 "$DATA_DIR/history.log" 2>/dev/null || echo never)"
    echo "  Status: OK"
}

_search() {
    local term="${1:?Usage: regexr search <term>}"
    echo "Searching for: $term"
    for f in "$DATA_DIR"/*.log; do
        [ -f "$f" ] || continue
        local m=$(grep -i "$term" "$f" 2>/dev/null || true)
        if [ -n "$m" ]; then
            echo "  --- $(basename "$f" .log) ---"
            echo "$m" | sed 's/^/    /'
        fi
    done
}

_recent() {
    echo "=== Recent Activity ==="
    tail -20 "$DATA_DIR/history.log" 2>/dev/null | sed 's/^/  /' || echo "  No activity yet."
}

case "${1:-help}" in
    check)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent check entries:"
            tail -20 "$DATA_DIR/check.log" 2>/dev/null || echo "  No entries yet. Use: regexr check <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/check.log"
            local total=$(wc -l < "$DATA_DIR/check.log")
            echo "  [Regexr] check: $input"
            echo "  Saved. Total check entries: $total"
            _log "check" "$input"
        fi
        ;;
    validate)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent validate entries:"
            tail -20 "$DATA_DIR/validate.log" 2>/dev/null || echo "  No entries yet. Use: regexr validate <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/validate.log"
            local total=$(wc -l < "$DATA_DIR/validate.log")
            echo "  [Regexr] validate: $input"
            echo "  Saved. Total validate entries: $total"
            _log "validate" "$input"
        fi
        ;;
    generate)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent generate entries:"
            tail -20 "$DATA_DIR/generate.log" 2>/dev/null || echo "  No entries yet. Use: regexr generate <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/generate.log"
            local total=$(wc -l < "$DATA_DIR/generate.log")
            echo "  [Regexr] generate: $input"
            echo "  Saved. Total generate entries: $total"
            _log "generate" "$input"
        fi
        ;;
    format)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent format entries:"
            tail -20 "$DATA_DIR/format.log" 2>/dev/null || echo "  No entries yet. Use: regexr format <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/format.log"
            local total=$(wc -l < "$DATA_DIR/format.log")
            echo "  [Regexr] format: $input"
            echo "  Saved. Total format entries: $total"
            _log "format" "$input"
        fi
        ;;
    lint)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent lint entries:"
            tail -20 "$DATA_DIR/lint.log" 2>/dev/null || echo "  No entries yet. Use: regexr lint <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/lint.log"
            local total=$(wc -l < "$DATA_DIR/lint.log")
            echo "  [Regexr] lint: $input"
            echo "  Saved. Total lint entries: $total"
            _log "lint" "$input"
        fi
        ;;
    explain)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent explain entries:"
            tail -20 "$DATA_DIR/explain.log" 2>/dev/null || echo "  No entries yet. Use: regexr explain <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/explain.log"
            local total=$(wc -l < "$DATA_DIR/explain.log")
            echo "  [Regexr] explain: $input"
            echo "  Saved. Total explain entries: $total"
            _log "explain" "$input"
        fi
        ;;
    convert)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent convert entries:"
            tail -20 "$DATA_DIR/convert.log" 2>/dev/null || echo "  No entries yet. Use: regexr convert <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/convert.log"
            local total=$(wc -l < "$DATA_DIR/convert.log")
            echo "  [Regexr] convert: $input"
            echo "  Saved. Total convert entries: $total"
            _log "convert" "$input"
        fi
        ;;
    template)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent template entries:"
            tail -20 "$DATA_DIR/template.log" 2>/dev/null || echo "  No entries yet. Use: regexr template <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/template.log"
            local total=$(wc -l < "$DATA_DIR/template.log")
            echo "  [Regexr] template: $input"
            echo "  Saved. Total template entries: $total"
            _log "template" "$input"
        fi
        ;;
    diff)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent diff entries:"
            tail -20 "$DATA_DIR/diff.log" 2>/dev/null || echo "  No entries yet. Use: regexr diff <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/diff.log"
            local total=$(wc -l < "$DATA_DIR/diff.log")
            echo "  [Regexr] diff: $input"
            echo "  Saved. Total diff entries: $total"
            _log "diff" "$input"
        fi
        ;;
    preview)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent preview entries:"
            tail -20 "$DATA_DIR/preview.log" 2>/dev/null || echo "  No entries yet. Use: regexr preview <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/preview.log"
            local total=$(wc -l < "$DATA_DIR/preview.log")
            echo "  [Regexr] preview: $input"
            echo "  Saved. Total preview entries: $total"
            _log "preview" "$input"
        fi
        ;;
    fix)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent fix entries:"
            tail -20 "$DATA_DIR/fix.log" 2>/dev/null || echo "  No entries yet. Use: regexr fix <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/fix.log"
            local total=$(wc -l < "$DATA_DIR/fix.log")
            echo "  [Regexr] fix: $input"
            echo "  Saved. Total fix entries: $total"
            _log "fix" "$input"
        fi
        ;;
    report)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent report entries:"
            tail -20 "$DATA_DIR/report.log" 2>/dev/null || echo "  No entries yet. Use: regexr report <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/report.log"
            local total=$(wc -l < "$DATA_DIR/report.log")
            echo "  [Regexr] report: $input"
            echo "  Saved. Total report entries: $total"
            _log "report" "$input"
        fi
        ;;
    stats) _stats ;;
    export) shift; _export "$@" ;;
    search) shift; _search "$@" ;;
    recent) _recent ;;
    status) _status ;;
    help|--help|-h) _help ;;
    version|--version|-v) _version ;;
    *)
        echo "Unknown: $1 — run 'regexr help'"
        exit 1
        ;;
esac

Security scan verdicts — ClawScan: suspicious | static analysis: clean | VirusTotal: clean | SkillSpector: suspicious (HIGH)