.foreach_part Macro

This macro iterates over the parts of a string divided by a delimiter using the special %CurrentPart% local variable.

.foreach_part (input [,"delimiter" [,head [,tail]]])
	output
.next[(separator)]

The following parameters are available:

Parameter

Description

input

Specifies the text over which to iterate.

Type: Simple template

delimiter

Specifies the sub-string that divides the input into parts. You can specify multiple characters including ranges. For example [A-Z] specifies that any capital letter acts as a delimiter.

By default, the delimiter is set to ' -_,\t' (space, dash, underscore, comma, or tab).

Note: The delimiter must be surrounded by single quotes if it contains a space.

Type: Text

head

[optional] Specifies text to be generated before the output, unless there is no output.

Type: Text

tail

[optional] Specifies text to be generated after the output, unless there is no output.

Type: Text

output

Specifies the text to output for each part in the input.

Type: Complex template

separator

[optional] Specifies text to be generated between each part of output.

Type: Text

For example:
Examples
This template is applied to My class:
.foreach_part (%Name%)
%.FU:CurrentPart%
.next
Result:
MyClass
This template is applied to My class:
.foreach_part (%Name%,' -_',tbl_)
%.L:CurrentPart%
.next(_)
Result:
tbl_my_class
This template is applied to MyClass:
.foreach_part (%Name%,[A-Z])
%.L:CurrentPart%
.next(-)
Result:
my-class