About Regex Splitter
When a list is held together by inconsistent separators, such as commas with and without spaces, stray semicolons or runs of blank lines, a plain split leaves a mess. Give this tool a JavaScript regular expression for the separator and it cuts the text at every match.
Trim each piece and drop the empty ones to tidy the result, keep the delimiters as items of their own when they carry meaning, and copy the pieces one per line or as a JSON array.
How it works
- Splitting follows JavaScript’s own String.split: an empty match at the very start, at the end or right after another match does not create a piece.
- Unlike String.split, capture groups in the pattern are not mixed into the result. Turn on Keep delimiters to list each whole delimiter between the pieces instead.
- Trimming happens before empty pieces are dropped, so a piece of only spaces counts as empty when both options are on.
- The split runs in a background worker and is stopped after three seconds, so a runaway pattern cannot freeze the page.
Questions
How do I split on any run of whitespace?
Use \s+ as the pattern. For blank lines between paragraphs use \n\s*\n, and for commas or semicolons with optional spaces use \s*[,;]\s*.
How do I split a word into characters?
Use an empty group, (?:), as the pattern. Turn on Unicode (u) so that emoji and other characters outside the Basic Multilingual Plane stay whole.
Why use JSON output?
If a piece contains a line break, the Lines output cannot show where it ends. A JSON array keeps every piece exact and is ready to paste into code.
How large a text can I split?
Up to 5 MB. Larger text is refused with a message before anything runs.
Everything you enter here is processed in this browser tab. Nothing is uploaded, logged or shared. How privacy works here.