Parameter
Iterates over every entry of the string and calls the closure function to work on the element of the string.
String
StringMap(String string, UDFMethod callback)
ColdFusion (2021 release): Added this function.
|
Parameter |
Description |
|---|---|
|
string |
(Required) The input string. |
|
callback |
(Optional) Closure or a function reference that will be called for each iteration. |
<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>
<cfscript>
myString="Hello World"
closure=function(val){
return (val & 'a')
}
writeOutput(StringMap(callback=closure,string=myString)) // Haealalaoa aWaoaralada
</cfscript>
Sign in to your account