<split>

Splits a string or list into pieces

<split> is a General Operator component that splits a numerical value or a text string into separate characters.

Attributes and Properties

Attributes for <split>

Other (3)
asList

boolean. Default value: true. Whether to render the items separated by commas (true) or with no separator (false).

keyword. How to break the input string into pieces.

ValueDescription
letter (default)Split into individual characters.
wordSplit into whitespace-separated words.
commaSplit on comma boundaries.
type

keyword. Type of value being split.

ValueDescription
textSplit text values.
Common to all components (9)
copy

reference. Create an independent copy of another component by reference. Enter a references a $name.

disabled

boolean. Default value: false. Whether this component is disabled and cannot be interacted with.

extend

reference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.

fixed

boolean. Default value: false. Whether this component's value is fixed and cannot be modified.

fixLocation

boolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

hide

boolean. Default value: false. Whether to hide this component from the rendered output.

isResponse

boolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.

name

text. The name used to reference this component from elsewhere in the document.

styleNumber

integer. Default value: 1. The style number used to select this component's visual styling from the available style definitions.

Properties for <split name="s">

Common to all components (4)
$s.doenetML

text. The DoenetML source code that produced this component.

$s.hide

boolean. Whether to hide this component from the rendered output.

$s.isResponse

boolean. Whether this component is treated as a response for the purposes of assessment.

$s.styleNumber

integer. The style number used to select this component's visual styling from the available style definitions.

Examples

Example: <split> numbers from user-input

In this example, a numerical value is split into separate digits that can be retrieved by by referring to the desired index of the named <split> component. Note that decimal points will occupy their own index.


Example: <split> a text string

In this example, a text string value is split into separate characters that can be retrieved by referring to the desired index of the named <split> component. Note that spaces and puncuation will occupy their own index.

Attribute Examples

Attribute Example: splitBy

For text strings, the splitBy attribute can be used to adjust the type of splitting that occurs. The options are comma, letter, and word.