Tcl Package Commands


NAME

nresplit - Split a string into a proper Tcl list using a regular expression

SYNOPSIS

package require nre ?3.0?
nresplit string ?regexp?

DESCRIPTION

Returns a list created by splitting string at each place that matches the regexp argument. Each element of the result list will consist of the characters from string that lie between instances of the text that matched regexp. The text that matched regexp is not included in the result listunless it is captured with ``()''.Empty list elements will be generated if string contains adjacent matches of regexp, or if it matches the text at the start or end of string. If regexp is an empty string then each character of string becomes a separate element of the result list. Regexp defaults to the standard white-space characters (i.e. "\s").

If regexp contains ``()'' then each captured string will be appended to the result after the text preceding the match. You can keep a subexpression from being appended by using ``(?:)'' instead of ``()''.

See the nrematch man page for a description of regular expressions.

This command is a super set of the standard split command. The only difference is that a regular expression is used as the splitter instead of a single set of characters.

nresplit is implemented using the nrematch command with the -split switch. See the nrematch for details on how you can create your own version of nresplit with additional features.

KEYWORDS

list, nre, split, regular expression, string

Last change: 3.0

[ nre3.0 ]

Copyright © 1997 Darrel Schneider.