Softanza
StartFrançais
Softanza
Reference · stzString

Section()

The substring from position n1 to n2 (inclusive, codepoint-aware).

also: substring slice part portion extract characters between two positions

also written: Slice

Basic examples (2)

Softanza
# 456
? StzStringQ("123456789").Section(4, 6)
Output
456

run on 2026-10-02 04:24 inside the library at commit 0e72e2e2c; taken from 788_section.ring(opens in a new tab)

Softanza
# chars 1..6
? Q("NEXTAV TUNISIA").Section(:From = 1, :To = 6)
Output
NEXTAV

run on 2026-10-02 04:24 inside the library at commit 0e72e2e2c; taken from 521_section.ring(opens in a new tab)

Scope (8)

Softanza
o1 = new stzString("123456789")
# -3 counts from the end
? o1.SectionXT(3, -3)
Output
34567

run on 2026-10-02 04:24 inside the library at commit 0e72e2e2c; taken from 405_sectionxt.ring(opens in a new tab)

Softanza
o1 = new stzString("216;TUNISIA;227;NIGER")
# the field after the first ;
? o1.Section(5, o1.NextOccurrence( :Of = ";", :StartingAt = 5 ) - 1)
Output
TUNISIA

run on 2026-10-02 04:24 inside the library at commit 0e72e2e2c; taken from 698_section.ring(opens in a new tab)

Softanza
o1 = new stzString("123456789")
# 5 to 3 reads backwards
? o1.SectionXT(5, 3)
# 5 with length 3 reads forward
? o1.SectionXT(5, -3)
Output
543
567

run on 2026-10-02 04:24 inside the library at commit 0e72e2e2c; taken from 986_sectionxt.ring(opens in a new tab)

Softanza
o1 = new stzString("softanza")
# Section(4, 6) is 'tan'
? o1.Section(4, 6)
# Section(6, 4) auto-orders to the same
? o1.Section(6, 4)
Output
tan
tan

run on 2026-10-02 04:23 inside the library at commit 0e72e2e2c; taken from 152_section.ring(opens in a new tab)

Softanza
o1 = new stzString("12345678")
# Section(3, 5) spans positions 3..5
? o1.Section(3, 5)
# Section(5, 3) auto-orders to the same span
? o1.Section(5, 3)
Output
345
345

run on 2026-10-02 04:23 inside the library at commit 0e72e2e2c; taken from 18_section.ring(opens in a new tab)

Softanza
o1 = new stzString("<<♥♥♥>>--<<stars>>--<<♥♥♥>>")
# BetweenIB(3, 5) is the heart run
? o1.BetweenIB(3, 5)
# Section(3, 5) gives the same
? o1.Section(3, 5)
Output
♥♥♥
♥♥♥

run on 2026-10-02 04:23 inside the library at commit 0e72e2e2c; taken from 185_betweenib.ring(opens in a new tab)

Softanza
# 4 mirrored is a single char
? Q("SOFTANZA").Section(4, :@)
# the 3rd-to-last mirrored
? Q("SOFTANZA").Section(:NthToLast = 3, :@)
# both mirrored is everything
? Q("SOFTANZA").Section(:@, :@)
Output
T
A
SOFTANZA

run on 2026-10-02 04:24 inside the library at commit 0e72e2e2c; taken from 523_section.ring(opens in a new tab)

Softanza
o1 = new stzString("what a <<nice>>> day!")
# a single char
? o1.Section(3, 3)
# the word
? o1.Section(10, 13)
# reversed indexes auto-order
? o1.Section(13, 10)
Output
a
nice
nice

run on 2026-10-02 04:24 inside the library at commit 0e72e2e2c; taken from 531_section.ring(opens in a new tab)

and 9 more in the tests

The extensions of this method

Each extension, and whether it exists for this method; an extension that exists combines with the others (FindSTCS).

Extension
Exists
What it adds · The names
Q
yes
does what the method does, then returns the object, so the call can be chained · SliceQ, SectionQ, SliceXTQ, SectionXTQ
QQ
no
chains on the next, more specific type of object (the Q ladder)
QQQ
no
chains on the most specific type of object (the Q ladder)
QRT
no
returns the result as an object of the requested type
CS
no
takes a case-sensitivity flag
ST
no
takes the position to start from (StartingAt)
IB
no
takes bounds that are included (IncludingBounds)
XT
yes
the extended form: more parameters than the base method · SliceXT, SectionXT, SliceXTQ, SectionXTQ
XTT
no
yet another extension: a further extended form, after XT
Z
no
includes the position in what it returns
ZZ
no
returns positions as sections, [start, end]
W
no
selects by a condition
WF
no
selects by a condition, with the expressive keywords (@NextItem, @PreviousItem...)
D
no
takes a direction, forward or backward (Directional)
F
no
takes a function (the condition or the update is given as a function); the forms document also uses F for the future form, which defers the action
Many
no
works on a collection of items instead of one (the plural form)
Except
no
takes exceptions, what to leave out (the exceptional form)
U
no
returns the result without duplication

Every example is a test file of the library, run inside the library for this page; only those whose output kept every promise their file wrote are shown.

See also