Test JavaScript regular expressions against sample text. Inspect match positions and capture groups before using a pattern in your code.
How to use
Enter the text, put the pattern in its field without slash delimiters, and set flags such as g or i. Inspect the returned matches.
Example
Pattern \d+ with flag g finds 42 and 99 in Order 42 and order 99. Match positions start at zero.
FAQ
Will results match every regex engine?
No. Syntax follows JavaScript. A worker stops long runs after about one second, and output is capped at 1,000 matches.
Related tools
A practical task
Start with examples that should match and examples that should not. A pattern for an order number needs both valid order strings and near misses. Check capture groups as well as whole matches so later extraction returns the intended field.
Another useful question
Why did a difficult pattern stop?
A timeout protects the page from excessive work. Simplify nested repetition and test shorter samples instead of assuming a stalled pattern is correct.
Settings and formats
| Field | Values |
|---|---|
| Pattern | Starting value: \d+ |
| Flags | Starting value: g |
Details for interpreting the result
| Detail | Explanation |
|---|---|
| Regex engine | Regular expression syntax belongs to an engine. A pattern accepted by JavaScript can differ from a pattern in another language. Test the exact engine and flags used in the application that will run it. |
| Regex flags | Flags alter matching rules. Global matching finds more than the first match; case insensitive matching changes letter comparisons. A repeated or unsupported flag is an input error, not a reason to change the source text. |
| Match positions | JavaScript string indices count UTF16 code units from zero. They do not always equal the number of visible symbols before a match. This matters when text contains emoji or other supplementary characters. |
| Pattern and literal search | A literal search matches the typed characters. A regular expression describes a pattern with operators. Characters such as dots and brackets have different roles in the two systems, so choose the right search mode. |
| Case sensitivity | Case sensitive matching distinguishes capital and lowercase letters. Ignoring case merges some of those distinctions, but it does not turn different spellings or word forms into the same term. |
| Code points | A Unicode code point identifies a character or a component of one. A letter followed by a combining accent contains two code points even when the screen displays one accented letter. |
| Visible symbols | What looks like one symbol can contain several Unicode components. Emoji sequences can include a base symbol, a skin tone, and joining characters. Counting or splitting them by bytes changes their structure. |