Regex Splitter

Write a regular expression for the separators and paste your text. The text is cut wherever the pattern matches, and the pieces come out one per line, ready to copy.

How it works

The text is split with JavaScript's String split, using your pattern as the separator. Wherever the pattern matches, the text is cut, and the match itself is dropped.

A part of the pattern in brackets is a capture group, and split keeps what it matched as a piece of its own. To group without keeping, write (?:...) instead.

Trim spaces and Drop empty lines are on to start, so the pieces come out clean. The split runs in a background worker with a one-second limit, and nothing leaves this page.

How to use it

  1. 1 Type a pattern for the separator in the Pattern box, without the slashes.
  2. 2 Paste your text. The pieces appear as you type.
  3. 3 Switch Trim spaces, Drop empty lines or Each value once on or off to suit the list.
  4. 4 Copy the list, or download it as a .txt file.

Good to know

  • The starting pattern, \s*[,;|]\s*, splits on a comma, semicolon or bar and eats the spaces around it, so mixed lists come apart cleanly.
  • To split on any run of spaces, tabs or line breaks, use \s+.
  • To split before each capital letter, as in camelCase words, use a lookahead: (?=[A-Z]). The capital stays with the piece that follows.
  • Turn off Drop empty lines if empty pieces matter, such as missing values between two commas.

Browser support

  • Chrome 94 and later
  • Firefox 93 and later
  • Safari 16.4 and later
  • Edge 94 and later

These are the oldest versions with everything the tool uses. They are worked out from the tool itself, so they change when it does.

Version numbers checked on 2026-09-04.

Cutting text where the pattern says

Most text that holds a list was not written by a program. People separate items with commas, then with semicolons, then with a slash, and put spaces wherever they like. A list pasted from a document might read "apples, pears;bananas | plums,,cherries ; figs". Splitting it on the comma alone leaves "pears;bananas | plums" as one item. A regular expression can describe every separator at once, and this tool cuts the text at each one.

The pattern on the page, \s*[,;|]\s*, reads as: any spaces, then a comma, a semicolon or a bar, then any spaces. Each match is a separator, and the text between matches becomes a piece. On the example the result is apples, pears, bananas, plums, cherries and figs, one per line. The double comma between plums and cherries makes an empty piece, and Drop empty lines removes it. Trim spaces removes any leftover spaces at the ends of each piece.

Capture groups behave in a way that surprises people the first time. When the separator pattern contains brackets, JavaScript's split keeps the text the brackets matched and puts it in the list between the pieces. Sometimes that is useful. Splitting "3+4-2" on ([+-]) gives 3, +, 4, -, 2, keeping the operators. Usually it is not what you want, and the fix is to write the group as (?:...), which groups without capturing. Lookaheads are another useful trick. The pattern (?=[A-Z]) matches the empty space before each capital letter, so "parseJsonInput" splits into parse, Json and Input without losing any letters.

There are cases a regex split cannot handle well. Quoted CSV is the common one. In the line "Smith, Ann",42 the comma inside the quotes is part of a name, but a pattern that splits on commas cannot tell. Use a CSV tool for that. Nested brackets, such as function arguments, are another. A regular expression cannot count nesting depth, so it cannot know which comma is at the top level. For those, a proper parser is the right tool.

The split runs in your browser's JavaScript regex engine, inside a background worker. If a pattern runs for more than one second, which can happen with nested quantifiers on long text, the worker is stopped and you get a message, so the page never freezes. The flags for ignoring case, line anchors, dot matching line breaks and Unicode are all available. Each value once removes repeated pieces, keeping the first. Your text stays on the page the whole time, and the result can be copied or downloaded as a plain text file.

Frequently asked questions

Why do some separators appear in my list?

Your pattern has a capture group in brackets, and split keeps whatever a capture group matched as an extra piece. Write the group as (?:...) to group without keeping it.

How is this different from splitting on a single character?

A plain split needs one fixed separator. A pattern can describe many at once, such as "a comma or a semicolon, with any spaces around it", or a separator that depends on context, such as a full stop followed by a space and a capital letter.

Can I use this to split a CSV line?

Only for simple lines. A CSV field in quotes can contain commas, and a regex split will cut it in two. For real CSV, use a CSV tool that understands quotes, such as the Column Splitter.

Is my text uploaded?

No. The split runs in a worker in your browser, and the text never leaves the page.

Related tools

Your files are processed on your device and are not uploaded. You can verify this in your browser’s developer tools under the Network tab.