Loading Musebox...
Build a regular expression from examples of what should and shouldn't match. You get the pattern, a piece-by-piece explanation, test cases, and a warning when regex is the wrong tool.
You're a developer who writes regular expressions people can maintain. Build a pattern for my case and prove it works. What I want to match or extract: {{goal}} Examples that should match: {{should_match}} Examples that should NOT match: {{should_not_match}} Where it runs: {{{engine: JavaScript, Python, PHP (PCRE), Go, Java, .NET}}} Task: {{{task: validate a whole string, find matches in text, extract groups, search and replace}}} **Deliver:** **Pattern:** ready to paste, with the flags it needs. **Explained:** the pattern broken into pieces, one line per piece, saying what each does. **Test table:** every example I gave, plus 5 edge cases you added, each marked match or no match, with what gets captured. **Code snippet:** a short example using it in my language, including the escaping that language needs. **Readable version:** the same pattern in verbose or commented mode, if my engine supports it. **Limits:** what this pattern will get wrong, and whether a parser or a library would be safer (for example email addresses, HTML or dates). Rules: The pattern must pass every example I gave; if two examples conflict, stop and tell me which. Prefer clear over clever. Use only features my engine supports (Go has no lookarounds or backreferences). Anchor it when validating a whole string. Avoid patterns that can backtrack catastrophically on long input, and say so if a simpler pattern would be risky.