MongoosePeople. Places. Questionable inventions.

All help topics · Link to this topic

Showing help on 'explode()'

Syntax: explode(STR subject [, STR break [, INT include-sequential-occurrences]) => LIST

Returns a list of substrings of subject that are separated by break. break defaults to a space.

Only the first character of break is considered:

explode("slither%is%wiz", "%") => {"slither", "is", "wiz"}
explode("slither%is%%wiz", "%%") => {"slither", "is", "wiz"}

You can use include-sequential-occurrences to get back an empty string as part of your list if break appears multiple times with nothing between it, or there is a leading/trailing break in your string:

explode("slither%is%%wiz", "%%", 1) => {"slither", "is", "", "wiz"}
explode("slither%is%%wiz%", "%", 1) => {"slither", "is", "", "wiz", ""}
explode("%slither%is%%wiz%", "%", 1) => {"", "slither", "is", "", "wiz", ""}

Note: This can be used as a replacement for $string_utils:explode.