Regex Text Splitter
Split text using a regular expression as the delimiter — runs of whitespace, several separators at once, blank lines between paragraphs, or any pattern a plain character cannot express. Add a second pattern to split each row into fields and get a table. Output as lines, JSON, CSV, TSV, numbered or a custom join. Nothing is uploaded.
About this tool
Most splitters ask for a single character. Real pasted data rarely cooperates: columns are separated by runs of spaces and tabs, a list mixes commas and semicolons, records are divided by blank lines, or the delimiter is a word rather than a symbol. This tool takes a regular expression as the separator — everything between matches of your pattern becomes a part.
Note the direction: the pattern describes the delimiter, not the data. \s+ splits on
whitespace; it does not extract whitespace. If you want the matches themselves, that is a
different job (matching, not splitting).
Add a field pattern and each row is split again, so delimited text becomes a real table you can render as CSV, TSV or nested JSON. Everything runs locally in your browser — the text you paste never leaves the page.
Worked example
Input text:
host: web1
region: eu-west
role: api
Split pattern \n, field pattern \s*:\s*, output CSV:
host,web1
region,eu-west
role,api
Leave the field pattern blank and the same input with pattern \n gives one line per row instead.
Switch the output to JSON array and you get [["host", "web1"], …] — nested arrays once a
field pattern is set, a flat array of strings without one.
What you can control
- Split pattern — the separator regex (Rust regex syntax).
\s+for runs of whitespace,[,;|]to accept several delimiters at once,\n{2,}for blank-line-separated paragraphs,\s*,\s*for commas with sloppy spacing,--for a multi-character separator. - Field pattern — an optional second regex applied to every row, producing columns.
- Output format — one part per line (default), JSON array, CSV, TSV, a numbered list, or all parts joined by a separator of your choice.
- Join separator — used only by the joined output format; the escapes
\n,\t,\rand\\are recognised, so\n\nputs a blank line between parts. - Max splits — stop after N splits and keep the remainder intact as the final row.
1onERROR: disk full: /dev/sda1with pattern:\s*yieldsERRORanddisk full: /dev/sda1. - Regex flags — ignore case (
i), multiline^/$(m), and dot-matches-newline (s). They apply to both patterns. - Trim each part and remove empty parts — clean up leading, trailing and repeated separators.
Limits and edge cases
- Input is capped at 200,000 characters and 100,000 parts; anything larger returns an explanatory error instead of hanging the tab.
- A separator at the very start or end of the text produces an empty part on that side — that is standard split behaviour. Turn on remove empty parts to drop them.
- A pattern that can match the empty string (
b*,\b) matches at every position and splits between every character; that usually hits the parts limit and is nearly always a pattern bug. - An empty split pattern is rejected — splitting on nothing is meaningless. To get one character per line, use a character-splitting tool instead.
- With remove empty parts on, a row whose fields are all empty is dropped entirely; if that removes everything, you get an error rather than blank output.
- The regex engine is linear-time and has no backtracking, so catastrophic-backtracking patterns cannot freeze the page — but it also does not support backreferences or lookaround.
FAQ
How is this different from splitting on a plain character?
A plain delimiter has to match exactly. If your data is separated by two spaces in one place and a
tab in another, a literal split leaves empty parts and ragged columns. The pattern \s+ treats any
run of whitespace as one separator, and [,;|] accepts three different delimiters in the same
input. Anything you can describe as a regex works — including multi-character separators like
, or --, and word separators like \s+then\s+.
How do I split into columns as well as rows?
Set the split pattern to whatever divides your records — usually \n — and the field
pattern to whatever divides the values inside a record, such as \s*:\s*, \t or \s{2,}.
Then pick CSV, TSV or JSON as the output format. Without a field pattern the tool produces a
one-dimensional list of parts.
Why do I get an empty first or last part?
Because the text begins or ends with the separator. Splitting ,a,b, on , produces four parts:
an empty one, a, b, and another empty one. That is correct split behaviour, not a bug — turn on
remove empty parts to drop them, and trim each part if the parts also carry stray spaces.
Which regex syntax is supported?
Rust's regex syntax: character classes, quantifiers, groups, alternation, anchors, Unicode
classes like \p{L}, and inline flags. It is a linear-time engine, so backreferences and
lookaround ((?=…), (?<=…)) are not supported — a pattern using them returns an
"invalid pattern" error naming the problem. The i, m and s flags are available as
checkboxes rather than inline flags, though inline forms like (?i) work too.
What does max splits do?
It caps how many times the input is cut into rows, keeping everything after the last cut as the
final part. This is the classic "split off the first N fields" behaviour: with pattern :\s* and
max splits 1, the line ERROR: disk full: /dev/sda1 becomes ERROR and disk full: /dev/sda1
instead of three parts. 0 means unlimited. Field splitting is never capped.
Is my text uploaded anywhere?
No. The splitter is compiled to WebAssembly and runs entirely inside your browser tab, so the text never leaves your machine. The same engine is available offline through the command line, which is useful for files bigger than the page's limit.
Developer & Automation Access
Run it from the terminal
Same engine as this page, headless — via the gizza CLI:
gizza tool text-splitter-regex "alpha beta gamma
delta,epsilon" 'pattern=\s+'New to the CLI? Get gizza →
Open it by URL
Pre-fill and auto-run this tool with query parameters — the names match the API/CLI:
https://gizza.ai/tools/text-splitter-regex/?text=alpha%20%20%20beta%09%09gamma%0Adelta%2Cepsilon&pattern=%5Cs%2B&field_pattern=%5Cs%2A%3A%5Cs%2A&output=lines&separator=%2C%20or%20%5Cn%5Cn%20or%20---&max_splits=0&ignore_case=true&multiline=true&dotall=true&trim=true&remove_empty=trueMachine-readable descriptor: tool.json — title + parameters JSON Schema for agents.
