Split text with a regex delimiter

Split text wherever a regular-expression separator matches.

freeworks offlinenothing uploaded
ToolRegex Split
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

The expression is applied as a separator and text between matches becomes fields; capturing groups can be inserted into the result. A limit stops collection after the requested number of entries.

  • Regex separators handle repeated punctuation and whitespace.
  • A limit controls output size.

Worked example

Split comma-separated values
Split a comma-separated line into individual values
Input
											John, 30, New York, Engineer
										
Output
												[0]: John
[1]: 30
[2]: New York
[3]: Engineer
											

When to use this

Log tokenization, punctuation splitting, and CSV-like preprocessing use regex separators.

Edge cases

  • A zero-width separator can create empty fields.
  • Capturing groups appear in the returned array.
  • Adjacent separators produce empties unless consumed together.

References