Replace
Replaces occurrences of substring1 in a string with obj, in a specified scope.
The search is case-sensitive. Function returns original string with replacements made
Method Signature
Arguments
Argument
Type
Required
Description
Default
string
string
true
The string to search
substring1
string
true
The substring to search for
obj
any
true
The string to replace substring1 with
scope
string
true
The scope to search in
one
Examples
Replace uppercase 'U' with lowercase 'u'
Replace in Script Syntax
Result: Boxlang
Replace uppercase 'O' with lowercase 'o', but only once
Something similar in Tag Syntax
Result: Boxlang
Example using Callback Function
You can pass in a callback function to the third argument of the replace
function
Result: A mAN a plAN a cANal.
Example with start argument (Replace lowercase 'o' with uppercase 'O' from the third position)
You can pass position to start searching in the string
Result: Love Boxlang
Additional Examples
Related
Last updated
Was this helpful?