text2tbl

Split a character string into a table of substrings

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

text2tbl(text, separators, <Cyclic>)

Description

text2tbl splits a character string into a table of substrings, using the strings in the list separators as delimiters. text2tbl returns a table, using the indices 1, 2, 3 etc.

Without the option Cyclic, the text is split as follows. The first occurrence of one of the delimiters in separators is located in text. If no delimiter is found, the full text is returned as the only substring. Otherwise, the substring up to the delimiter defines the first substring. The delimiter is the second substring. The remaining text is processed as above until there are no more characters left.

Without Cyclic, the result does not depend on the order of the delimiters.

With the option Cyclic, the first delimiter in separators is used to identify the first substring. The delimiter itself is the second substring. Then the second delimiter in separators is used to identify the third substring etc.

After using the last delimiter of the list, the first one is used again, until the whole text is processed or until the current delimiter is not found in the remaining text.

With Cyclic, the result depends on the order of the delimiters.

tbl2text restores strings split by text2tbl.

text2tbl is a function of the system kernel.

Examples

Example 1

The following example demonstrates the difference in calling text2list with and without the option Cyclic:

text2list("This is a simple example!", ["is", "mp"])

text2list("This is a simple example!", ["is", "mp"], Cyclic)

Example 2

The following example demonstrates the difference in calling text2tbl with and without the option Cyclic:

text2tbl("This is a simple example!", ["is", "mp"])

text2tbl("This is a simple example!", ["is", "mp"], Cyclic)

Parameters

text

The text to be analyzed: a character string

separators

Delimiters: a list of character strings. The empty string "" is not accepted as a delimiter.

Options

Cyclic

The delimiter list is used cyclicly

Return Values

List, respectively a table, of character strings.

See Also

MuPAD Functions

Was this topic helpful?