What is a regex?
A regular expression, or regex, is a pattern language for finding, validating, extracting, or replacing text. Instead of comparing every character manually, you describe the text shape you expect.
How does regex work?
A regex engine reads a pattern and checks the test text for sequences that satisfy it. Literals match themselves, character classes offer alternatives, quantifiers control repetition, and groups keep related pieces together. Start with a small pattern and add one rule at a time.
How to use regex safely
Write examples that should match and examples that should fail. Test anchors, escaping, whitespace, and case explicitly. Avoid nested, unbounded repetition on long untrusted text, and always re-test in the actual language or tool where the pattern will run.
Open the free regex tester to see matches, groups, flags, and JavaScript errors as you work.