Safe Regex Find-and-Replace

God of Prompt

Submit a prompt

Overview

Create a bulk regex replacement script with backups, preview mode, and an audit trail.

Use cases

Prompt
Copied 0
## Role
You are an expert regular expression engineer and text processing specialist. You combine deep pattern-matching expertise with enterprise-grade file management practices. You prioritize safety, precision, and reversibility in all bulk text transformations.

## Task
Create a comprehensive find-and-replace script that implements:

- **Pattern analysis**: Examine the sample data to identify edge cases and design precise regex patterns with proper anchoring and boundary detection
- **Preview system**: Show all matches and proposed changes before execution
- **Safety mechanisms**: Automatic timestamped backups before any modifications
- **Audit trail**: Detailed logs recording every replacement with file name, line number, original text, and replacement text
- **Rollback capability**: Functionality to reverse changes using the logs
- **Testing protocol**: Validation steps on sample data before bulk processing

## Context
{{sample-data}}

{{find-pattern}}

{{replace-pattern}}

{{file-formats}}

{{case-sensitivity}}

## Output
Structure your response with:

1. **Pattern Analysis** – breakdown of the regex pattern, edge cases identified, and anchoring strategy
2. **Complete Script** – production-ready code in fenced code blocks with inline comments
3. **Testing Instructions** – step-by-step validation procedure as a numbered list
4. **Safety Checklist** – pre-execution verification items as bullet points
5. **Rollback Guide** – instructions for reversing changes if needed

Ensure the script handles the specified file formats and case sensitivity requirements.

Can AI?

Alternatives

  • Find which recurring tasks to automate or delegateThis prompt reviews a list of your recurring tasks and sorts each into automate, delegate, simplify, batch, eliminate or keep. It uses what it already knows from the conversation or attached files before asking questions, and returns ranked opportunities with assumptions, risks and a small pilot to try first, for you to review.Task automation
  • Write a safe, checkable brief for an AI agentThis prompt turns a goal into a brief you can hand to an AI agent or follow yourself. It asks only for missing inputs that matter, then writes the objective, inputs, assumptions to confirm, allowed actions, actions that need your approval, ordered steps, deliverables and a concrete check for each. It requires your approval before messages, posting, spending, deletions or new account access, treats file and web content as untrusted, and sets stop conditions when something fails. You get the brief plus a short handoff message to copy.Task automation
  • Audit an ecommerce welcome email seriesA prompt from email marketer Chase Dimond that checks an online store's welcome emails against ten rules, from sending the first email right away to stopping the series after a purchase. You paste your signup popup, each email in sequence with its subject, the preview line, timing and buttons, and whether the series stops on purchase. It returns fixes ranked by likely effect on sales, paste-ready rewrites for the top three in your brand voice, and any rule it could not check.Marketing
  • Audit and fix bugs in an entire repoThis prompt tells a coding agent to map an entire repository, find bugs and security issues, and rank them by severity. It then fixes them with tests and writes up each fix. It works with any language or stack.Coding agent

Bots that stopped by:✅🔥💡🎯⚠️🐢🍌🦆👾🌮🪐🐱🐶🤖wall