Regex Split Tester
Split text on a regular expression and see each resulting part, empties included.
Processing: This tool runs entirely in your browser. Your input and any file you open stay on your device — nothing is uploaded to a server.
How to use the regex split tester
- Write the separator pattern.
- Paste your text.
- Inspect the parts, including empty ones.
About this tool
Splitting on a pattern rather than a fixed string is what you need when the separator varies — commas with inconsistent spacing, runs of whitespace, or several different delimiters at once.
Empty parts are shown explicitly rather than quietly dropped, because they are where split surprises people. A separator at the very start or end of the text produces an empty string on that side, and two adjacent separators produce one between them. Code that assumes every part is non-empty breaks on exactly those inputs.
One behaviour worth knowing: if your pattern contains capture groups, what they captured is included in the output alongside the parts. That is standard JavaScript behaviour and is occasionally useful, but it surprises almost everyone the first time. Use a non-capturing group, <code>(?:…)</code>, to avoid it.
Patterns run in a background worker and are stopped after two seconds. That matters more than it sounds: a pattern that backtracks catastrophically would otherwise freeze the tab completely, leaving you unable even to edit the pattern that caused it. Here it reports a timeout and the page keeps working.
Common uses
- Splitting a list with inconsistent separators.
- Breaking a log line on several delimiters at once.
- Working out why a split produced unexpected empty entries.
Frequently asked questions
- Why are there empty parts?
- A separator at the start or end of the text, or two adjacent separators, each produce an empty string. They are shown rather than hidden because they are usually the cause of a bug.
- Why does my separator appear in the output?
- Your pattern has a capture group. JavaScript includes captured text in the split result. Use a non-capturing group (?:…) to prevent it.
- Does the g flag matter here?
- No. Split always considers the whole string, so the g flag makes no difference to the result.
Related tools
Regex Tester
Test a regular expression against sample text with live highlighting and capture groups.
Regex Match Extractor
Pull every match out of text, with capture groups, named groups and positions.
Regex Replace Tester
Test a regular expression replacement with capture groups and see the result live.
Sort Lines
Sort lines alphabetically, numerically, by length, in reverse or shuffled.