ZapKit

Split text by regex

Break messy lists into clean items when the separators vary: commas here, semicolons there, pipes and stray spaces everywhere.

What does splitting by regex mean?

Splitting by regex cuts text into pieces wherever a regular expression matches, rather than at one fixed character. It's the reliable way to break apart lists typed by people, tags pasted from different tools, and log fields separated by varying amounts of space.

Type the separator pattern and optional flags, decide whether to trim pieces and drop empty ones, and choose how to join the result: one per line, comma separated, tab separated for spreadsheets, or a JSON array for code. Counts show the pieces kept and the empty ones dropped.

How to use the Split text by regex

  1. 1.Paste the text

    A list, a log line or any delimited text.

  2. 2.Write the separator pattern

    The default splits at commas, semicolons and pipes.

  3. 3.Choose the output

    Lines, commas, tabs or a JSON array.

Example: a messy fruit list

"apples, pears;bananas | grapes, oranges;;kiwis" split with \s*[,;|]\s*:

Pieces
6: apples, pears, bananas, grapes, oranges, kiwis
Empty dropped
1 (from the double ;;)

A clean list whatever separators the person typing chose.

Patterns beat single characters

A plain split only handles one separator. A pattern such as \s*[,;|]\s* handles all three and swallows surrounding spaces in one go; \s+ splits on any run of whitespace; \r?\n\s*\r?\n splits paragraphs.

Back-to-back separators create empty pieces, which can be dropped, and every piece can be trimmed. If the pattern contains capture groups, the captured separators are included in the result, as JavaScript's split does. Splitting runs instantly on long text, so pasting a whole log file is fine.

Frequently asked questions

How do I split on words like AND?

Use \s+and\s+ with the i flag to ignore case.

Can I keep the separators?

Yes. Wrap the pattern in a capture group, like ([,;]).

How do I make a JSON array?

Set Join with to JSON array.

Is the text saved?

No. It isn't stored anywhere.

More Developer tools