Skip to main content

split

Splits a string around matches for a specific character or sequence of characters.

You can also use a pattern of characters known as a regular expression or regex.

Strings matching the expression are removed, and the output is a list of substrings.

Parameters

  • STRING (string)

    The input string.

  • REGEX (string)

    A character, sequence of characters, or regular expression.

  • LIMIT (number)

    Optional. The number of substrings in the result.

    Default: No limit

Examples

These examples were produced in a project with these settings:

Setting

Value

CONJUNCTION

and

USE OXFORD COMMA

No

SEPERATOR

,

ENABLE AUTOMATIC SENTENCE CAPITALISATION

No

You can split the string around one character.

ATL in Script

Printed Result

[[split('a string to be split', 'b')]]

a string to and e split

The output list has two substrings: 'a string to' and 'e split'. The matching 'b' in the input string is removed.

Note

As per the project settings, the list is printed with a conjunction.

You can use a regular expression in the second parameter.

ATL in Script

Printed Result

[[split('John jumps, John skips. John hops.', '. John')]]

John jumps, skips and hops.

The input to the second parameter — '. John' — is a regular expression. The period in the expression matches any character, so the expression matches ', John' and '. John' in the input string.

Note

As per the project settings, the list is printed with separators and a conjunction.

The third parameter allows you to limit the number of substrings.

ATL in Script

Printed Result

[[split('John jumps, John skips. John hops.', '. John', 2)]]

John jumps and skips. John hops.