StringEach()

edit

Iterates over a string and runs the closure function for each element in the string.

Introduced: 6.0.0.105

StringEach( string=string, closure=function );

Returns: void

Argument Description
string
string, required
edit

Input string.

Alias: inputString, object

closure
function, required
edit

Closure or a function reference that will be called for each of the iteration.

Alias: function, callback, udf

Usage Notes

edit

Since Lucee 6, this function iterates over each character in the string.

For list-based iteration with delimiters, use ListEach() instead.

LDEV-3747

Examples

edit
	inputString = "abcd";
	stringEach(inputString,
		function(val) {
			writeoutput(val == "c");
		}
	);

See also