Slice Text

Extract a character range using start and end offsets, including negative indexes from the end.

What Slice Text helps you do

Extract a range of characters using start and end offsets, including negative indexes counted from the end. This mirrors how string slicing works in most programming languages, so it is useful for reproducing or debugging that behaviour. The end offset is exclusive, and the whole text is treated as one string.

Slicing happens in your browser; your text is never uploaded to Haivix.

How it works

Line tools split the pasted text into lines, apply one operation to the list, and rejoin it with a newline. A blank line is still a line, so it participates in sorting, numbering and shuffling unless you remove it first. The transformation runs in the browser and keeps the existing line order except where the tool's purpose is to change it. Nothing is uploaded, and the output replaces the preview rather than the source. If the input ends with a newline, the final empty line can affect a count or a shuffle; trim the input first when that matters.

How to use Slice Text

  1. Paste the text and enter the start and end positions.
  2. Use negative values to count from the end, such as -5 for the last five characters.
  3. Read the extracted substring and check the boundaries.
  4. Copy the result.

When to use it

  • Grab a fixed-width field out of a log line.
  • Check what a slice expression returns before putting it in code.
  • Extract the last few characters of an identifier.
  • Remove a known prefix by slicing from an offset.
  • Reproduce a JavaScript slice result in another language.
  • Extract a date or code from a fixed position in a line.

When not to use it

  • Do not use it for word or line selection; it works on characters.
  • Do not use it on emoji-heavy text if exact grapheme boundaries matter.
  • Do not expect it to trim the extracted substring.

Example

Slicing abcdefgh from index 2 to 5 returns cde. A start of -5 returns the final five characters, and an empty end slices to the last character. The end offset is exclusive, so the character at that index is not included.

What you can do with Slice Text

  • Extract characters between a start and end offset.
  • Use zero-based indexes.
  • Use negative offsets to count from the end.
  • Leave the end empty to slice through the last character.
  • Copy the extracted substring.
  • Run the slice locally with no upload.

Example: check the line structure first

Paste a small sample and note how many lines it has, including blank lines and a possible trailing newline. The count explains most surprises after sorting, numbering or filtering.

Apply the operation and compare the first and last lines with the source. If the structure is right, run the full text; if not, remove the blank lines or trim the input first.

Copy or download the result and keep the original until the destination accepts it. Line tools are one-way, so the source is the only undo.

For a list pasted from a spreadsheet, check for hidden carriage returns or wrapping quotes before transforming it. A stray quote can sort differently or survive a filter that looks correct at a glance.

When the result feeds another tool, run a second pass only after confirming the first. Chaining a sort and a deduplication is safe, but chaining two numbering steps produces duplicated prefixes.

If the output is going into a version-controlled file, check the diff before committing. A blank-line or line-ending change can look like a content change in review even when the words are unchanged.

What to know before you start

  • Indexes are character-based and count UTF-16 code units, so some emoji and combined characters can split unexpectedly.
  • The end offset is exclusive, matching common programming conventions.
  • It does not operate line by line.
  • There is no preview of the selected range.

Common mistakes

  • Expecting the end offset to be inclusive.
  • Using a one-based index and shifting the result by one.
  • Splitting an emoji or a combined character because indexes count UTF-16 code units.
  • Forgetting that an empty end means the rest of the string.

Troubleshooting

If the result is one character short, the end offset is exclusive.

If the result is empty, the start may be after the end or beyond the string length.

If a symbol looks broken, the slice split a surrogate pair; adjust the boundaries.

If the result includes an unexpected character, recheck the zero-based start.

Related standards and documentation

  • A newline is a single line separator in Unix text; Windows files may use CRLF.
  • Modern JavaScript sorts are stable, so equal lines keep their relative order.
  • Blank lines are entries, not separators, in these transformations.
  • A trailing newline is a text convention, not content; remove it before counting lines.
Blank lines are still lines
  • Count the lines before you transform.
  • Remove blanks first when they should not participate.
  • Keep the original until the result is accepted.
  • Check the last line for a trailing newline.

Frequently Asked Questions