String Operations

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > String commands > !BLO.-Block-Commands > Content Extraction >

String Operations

BLO.AIGetNth

Previous Top Next


MiniRobotLanguage (MRL)

 

BLO.AIGetNth

Gets the Nth block using AI-resilient delimiters.

 

 

Intention

 

This Command is designed to extract blocks from text generated by Large Language Models (LLMs) or AI systems that often corrupt or hallucinate delimiters.

You provide a short base delimiter (1–2 characters, e.g., "**"), and the system automatically recognizes common AI variants such as:

"[**]" (ideal)

"[**" (unclosed)

"</**>", "[/**]" (doc-style)

"/*]", "/]" (generic close)

"**]", "/**]" (fragmented)

The system uses longest-match-first logic to prefer complete forms (e.g., "[**]") over partial ones (e.g., "[**").

 

Visual Example

 

Parsing AI-Corrupted Output

 

Source String:  start[**]HELLO[/**]middle</**>WORLD[**]TEST/*]end

                  └───┬───┘       └───┬───┘       └──┬──┘

                      │             │           │

                      ▼             ▼           ▼

Result (N=1):         "HELLO"

Result (N=2):         "WORLD"

Result (N=3):         "TEST"

 

 

Syntax

 

BLO.AIGetNth|P1|P2|P3|P4

 

Parameter Explanation

 

P1 - (Input, Text) The source string (often AI-generated).

P2 - (Input, Text) The base delimiter (1–2 characters, e.g., "**", "#").

P3 - (Input, Numeric) The block index to retrieve. 1 = first, -1 = last.

P4 - (Output, Variable) The variable to store the extracted content.

 

Example

 

'***********************************

' BLO.AIGetNth Example

'***********************************

$$SRC=start[**]HELLO[/**]mid</**>WORLD[**]end

BLO.AIGetNth|$$SRC|**|1|$$FIR

' $$FIR = "HELLO"

 

' Get last block

BLO.AIGetNth|$$SRC|**|-1|$$LAS

' $$LAS = "WORLD"

 

' Works with other base delimiters

$$TEXT=<##>Content</##>

BLO.AIGetNth|$$TEXT|##|1|$$RES

' $$RES = "Content"

MBX.!|$$RES

ENR.

 

 

See also:

 

BLO.PatternGetNth - Gets Nth block using abstract patterns (WR_AW)

BLO.MultiGetNth - Gets Nth block using multiple literal delimiters