RegEx Pattern Optimizer
By Mr Tech King · Published · Updated
Refines complex regular expressions for speed and clarity, helping developers eliminate backtracking and improve parsing performance.
Prompt template
Act as a senior performance engineer specializing in string processing. Your task is to analyze the provided regular expression and rewrite it to eliminate redundant operations, reduce catastrophic backtracking risk, and improve overall execution speed. Focus on converting verbose patterns into concise, atomic groups where appropriate. ## Details - Target Engine: [dropdown: PCRE, JavaScript, Python, Go, Rust] - Input Pattern: [textarea: Paste the original regex here] - Sample String: [text: Example text for testing] - Primary Goal: [multi: Speed, Readability, Memory, Compatibility] - Allow Lookaheads: [toggle: Yes, No] - Minimum Match Length: [1, 500] - Maximum Iterations: [1, 10000] ## Output Return a JSON object containing exactly three keys. The first key, 'optimized_pattern', holds the new regex string. The second key, 'explanation', provides a brief three-sentence summary of the specific changes made to improve performance. The third key, 'risk_score', is an integer from 1 to 10 indicating the remaining risk of catastrophic backtracking, where 1 is safe and 10 is dangerous. Do not include any markdown formatting or additional commentary outside the JSON structure.