Whatever message this page gives is out now! Go check it out!

StringMap

Last update:
May 18, 2026

Description

Iterates over every entry of the string and calls the closure function to work on the element of the string.

Returns

String

Category

Syntax

StringMap(String string, UDFMethod callback)

History

ColdFusion (2021 release): Added this function.

Parameters

Parameter
Description
string
(Required) The input string.
callback
(Optional) Closure or a function reference that will be called for each iteration.

Example

<cfscript> 
    myStr="123456789";   // ascii value of 1 is 49, 2 is 50 , and so on            
    closure=function(item){ 
        return item+5; 
    } 
    writeOutput(myStr.map(closure)) // 545556575859606162 
</cfscript>

Example 2

<cfscript> 
    myString="Hello World"         
    closure=function(val){               
      return (val & 'a')  
    } 
    writeOutput(StringMap(callback=closure,string=myString)) // Haealalaoa aWaoaralada 
</cfscript>

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page