How to use the regex tester
- Pick a preset at the top and a common pattern such as an email, phone number, URL or date is filled in together with a sample text. To write your own, keep "Custom" and type the pattern in the pattern box.
- Check flags (g, i, m, s, u, y) to change behavior. g finds all matches and i ignores case. On a phone, the symbol buttons under the box insert things like \d, [ ] and ( ) directly.
- Type your test text and the matches are painted alternately in yellow and green, with positions and capture group values in the table below.
- Enter a replacement string to preview the result using $1 or $
. A pattern with an error shows the reason in a red notice.
How it stays live and safe
After a short pause on each keystroke, the pattern is run with your browser's JavaScript regex engine. Matched text is not inserted into the page as HTML; text nodes and highlight elements are created separately, so even if your sample contains scripts or tags they are never executed and are shown only as text.
Regular expressions can become explosively slow, so this tool runs them in a background worker (Web Worker). After 1.5 seconds it stops the work and shows a notice, so the whole page does not freeze. It collects at most 1,000 matches and shows only the first 100 in the table, so a huge number of results does not slow the screen.
A quick regex syntax reference
Regular expressions are widely used for input validation (emails, phone numbers), finding patterns in logs, bulk text replacement and data cleanup. With the regex option on in an editor's find and replace, you can change the format of many lines at once. A hard-to-read regex is difficult to fix later, so leave an explanation next to it.
Symbols for a single character include . (any character except a line break), \d (digit), \w (letter, digit or underscore) and \s (whitespace). [abc] means one of these, [^abc] means any character except these, and [a-z] is a range. For positions, ^ is the start of a line or text, $ is the end and \b is a word boundary.
Repetition is written * (zero or more), + (one or more), ? (zero or one) and {n,m} (n to m times). The default is greedy, taking as much as possible, and adding ? (*?, +?) makes it lazy, taking as little as possible. Parentheses ( ) make a capture group, (?:...) a non-capturing group and (?
The flags are g (all matches), i (ignore case), m (^ and $ apply per line), s (. also matches line breaks), u (Unicode handling) and y (sticky, matching only at the current position). Use the presets as a starting point for checks like emails or phone numbers, but real services have many exceptions, so always test with varied input.
Tips for good results
- Do not start complex. Begin with a short pattern, watch the matches, and extend it gradually.
- A pattern like .* matches everything and can grab more than you intend. Narrow it with .*? or [^"]* when needed.
- To find special characters (. * + ? ( ) [ ] { } | ^ $ \) literally, put a backslash (\) before them.
- Avoid patterns with repetition inside repetition, such as (a+)+ or (.*)*. They get very slow on longer input.
- If you are checking personal data, do not put real personal information in the test text; use example values.
FAQ
Which regex syntax does it use?
It uses the JavaScript (ECMAScript) regex engine of your browser as is. Some syntax of other engines such as Python, Java or PCRE (for example possessive quantifiers or some inline flags) may differ. Lookbehind may not be supported in older browsers.
Why do I see "Processing took too long and was stopped"?
Patterns that nest repetition of the same characters, like (a+)+, try every possible path when they hit a character that does not match, so the time explodes as the input grows. This is called catastrophic backtracking. The tool stops the work after 1.5 seconds so the page does not freeze.
What happens if I turn off the g flag?
Without g only the first match is found, and replacement applies only to the first match. Keep g on to see all matches.
What can I use in the replacement string?
You can use $1, $2 for capture group numbers, $
Is my text sent anywhere?
No. Everything, including the background worker, runs inside this browser and nothing is sent to a server or stored.
Notes & limitations
This tool is for learning and testing with the JavaScript regex engine, and results can differ from regular expressions in other programming languages. The patterns and text you enter are never sent to a server or stored. Presets are only examples and do not validate every case, so test thoroughly before using them in a real service. BTSPACE WAGLE is an unofficial information site.