---
title: "stringx"
description: "Batch text-scanning kernels: read a whole run of numbers out of a string in one call."
section: "API Reference"
slug: "api-stringx"
canonical: "https://origozero.ai/docs/api-stringx"
updated: "2026-10-20T13:15:37.052451766+00:00"
tags: ["api", "reference"]
---

# stringx

Batch text-scanning kernels — read a whole run of numbers out of a string in one call.

```lua
require("@builtin::modules.api.engine.stringx") -- stringx (also available as global 'stringx')
```

The `stringx` namespace: 3 functions.

## globals/stringx/scanNumbers {#globals-stringx-scannumbers}

```lua
stringx.scanNumbers(s: string, pos: number?) -> ({ number }, number)
```

Read the run of numbers starting at `pos` — separated by commas and/or
whitespace — and report where the run ended.

The run stops at the first character that neither continues a number nor
separates two of them (`]`, `}`, a quote, a letter), and `nextPos` is that
character's index, so the caller's own parser resumes exactly there. A
token that is not a valid number also ends the run, with `nextPos` left ON
it rather than past it, so nothing is skipped without the caller seeing it.

**Parameters**

- `s` `string` — The text to read.
- `pos` `number` _(optional)_ — 1-based index to start at. Defaults to 1.

**Returns** `({ number }, number)` — The numbers found, and the 1-based position just past them.

```lua
-- A JSON array of numbers, in one crossing instead of one per token.
local values, nextPos = stringx.scanNumbers(payload, afterBracket)
-- A whitespace-separated block (OBJ, PLY, a matrix dump).
local m = stringx.scanNumbers("1 0 0 0  0 1 0 0", 1)
```

## modules/stringx/scanNumbers {#modules-stringx-scannumbers}

```lua
scanNumbers(s: string, pos: number?): ({ number }, number)
```

Read the run of numbers starting at `pos` — separated by commas and/or
whitespace — and report where the run ended.

The run stops at the first character that neither continues a number nor
separates two of them (`]`, `}`, a quote, a letter), and `nextPos` is that
character's index, so the caller's own parser resumes exactly there. A
token that is not a valid number also ends the run, with `nextPos` left ON
it rather than past it, so nothing is skipped without the caller seeing it.

**Parameters**

- `s` `string` — The text to read.
- `pos` `number?` _(optional)_ — 1-based index to start at. Defaults to 1.

```lua
-- A JSON array of numbers, in one crossing instead of one per token.
local values, nextPos = stringx.scanNumbers(payload, afterBracket)
-- A whitespace-separated block (OBJ, PLY, a matrix dump).
local m = stringx.scanNumbers("1 0 0 0  0 1 0 0", 1)
```

## typed/builtin//modules/api/engine/stringx/stringx/scanNumbers {#typed-builtin-modules-api-engine-stringx-stringx-scannumbers}

```lua
stringx.scanNumbers(s: string, pos: number?) -> ({ number }, number)
```

Read the run of numbers starting at `pos` — separated by commas and/or
whitespace — and report where the run ended.

The run stops at the first character that neither continues a number nor
separates two of them (`]`, `}`, a quote, a letter), and `nextPos` is that
character's index, so the caller's own parser resumes exactly there. A
token that is not a valid number also ends the run, with `nextPos` left ON
it rather than past it, so nothing is skipped without the caller seeing it.

**Parameters**

- `s` `string` — The text to read.
- `pos` `number` _(optional)_ — 1-based index to start at. Defaults to 1.

**Returns** `({ number }, number)` — The numbers found, and the 1-based position just past them.

```lua
-- A JSON array of numbers, in one crossing instead of one per token.
local values, nextPos = stringx.scanNumbers(payload, afterBracket)
-- A whitespace-separated block (OBJ, PLY, a matrix dump).
local m = stringx.scanNumbers("1 0 0 0  0 1 0 0", 1)
```
