Skip to content
UniKit

Line slice and join

Slice every line by character position (1-based, both ends inclusive, 0 for end of line), then join the sliced pieces with a chosen separator. Lines that end up empty can be dropped, and the input, kept and character counts are reported.

Runs in your browserEvery computation happens in your browser — your data never leaves this device.

Text to process (one item per line)

Joined result

Each line is sliced by character position, then joined with the separator. “Characters kept” counts characters, not bytes.

Paste a few lines to see the joined result

What this tool does

  • Strip a fixed-length prefix (order id, date, running number) from every line and keep the body.
  • Cut the value out of a key=value list by character position and join the pieces with a comma or a bullet.
  • Split a fixed-width export by column position and keep only one field, aligned per line.

Example

Input

2024-01-apple
2024-02-banana

Output

apple、banana

The default settings used by the example are start 9, end 0 (end of line) and the separator “、”: every line is sliced by character position, then the pieces are joined.

Frequently asked questions

How are positions counted?

In Unicode code points, 1-based and inclusive: start 9 keeps the 9th character and everything after it, and end 0 means end of line. Line breaks are not counted, and a Chinese character counts as one position (not three bytes).

Can an emoji be cut in half?

A plain emoji such as 😀 is a single code point, so slicing by position never produces half a surrogate pair. ZWJ sequences (e.g. 👨‍👩‍👧 = 👨 + ZWJ + 👩 + ZWJ + 👧) are several code points, so they can still be split — replace them first if you need them intact.

How are empty lines handled?

Lines that were already empty are always dropped and counted in “Lines dropped”. Lines that just became empty are kept by default; tick “Drop lines that end up empty” to remove them too. A trailing newline does not add an extra line, and both CRLF and LF count as line breaks.

What happens with invalid settings?

The tool errors instead of guessing: a start below 1, an end before the start, or a non-integer position raises an invalid-position error, and a non-text separator raises an invalid-separator error.

Keywords:line slice and join

Related tools