======replace====== Replace all occurrences of a value in a [[PTPScript:Types:String|String]], [[PTPScript:Types:Number|Number]], or [[PTPScript:Types:Array|Array]] with another value. \\ **Syntax** * ''[[PTPScript:Types:Mixed|Mixed]] replace( [[PTPScript:Types:Mixed|Mixed]] subject, [[PTPScript:Types:Mixed|Mixed]] search, [[PTPScript:Types:Mixed|Mixed]] replace [, [[PTPScript:Types:Boolean|Boolean]] strict ] )'' \\ **Parameters** * [[PTPScript:Types:Mixed|Mixed]] ''subject'' - The entity to search. * [[PTPScript:Types:String|String]] - The String is searched for any occurrences of ''search''. * [[PTPScript:Types:Number|Number]] - The Number will be treated as a String. * [[PTPScript:Types:Array|Array]] - The Array is searched for any items that match ''search''. * [[PTPScript:Types:Mixed|Mixed]] ''search'' - The value(s) to search for. * [[PTPScript:Types:String|String]] - ''subject'' is searched for any occurrences of the String. * [[PTPScript:Types:Number|Number]] - The Number will be treated as a String. * [[PTPScript:Types:Array|Array]] - If ''subject'' is a String, it is searched for any occurrences of //any// of the items in ''needle''. Otherwise, if ''subject'' is an Array, only sub-Arrays that match ''needle'' will be found. * [[PTPScript:Types:Boolean|Boolean]] - This only has any effect if ''subject'' is an Array, in which case, any occurrences will be searched for. * [[PTPScript:Types:Mixed|Mixed]] ''replace'' - The value(s) to use for replacement. * [[PTPScript:Types:String|String]] - All matches of ''search'' will be replaced with the String. * [[PTPScript:Types:Number|Number]] - The Number will be treated as a String. * [[PTPScript:Types:Array|Array]] - If ''subject'' is a String, and ''search'' is an Array, all matches will be replaced by the corresponding value in the ''replace'' Array - or an empty value if there are no corresponding items. Otherwise, if ''subject'' is an Array, ''replace'' will be used to replace matching sub-Arrays. * [[PTPScript:Types:Boolean|Boolean]] - This only has any effect if ''subject'' is an Array, in which case, all matches of ''search'' will be replaced. * [[PTPScript:Types:Boolean|Boolean]] ''strict'' - Whether to employ strict matching. * **''false''** (default) - If ''subject'' is a String, the match will be case-insensitive. Otherwise, if ''subject'' is an Array, item types will not be checked, only item values. * **''true''** - If ''subject'' is a String, the match will be case-sensitive. Otherwise, if ''subject'' is an Array, item types will have to match as well as values. Array searches are always case-sensitive. \\ **Result** * [[PTPScript:Types:Mixed|Mixed]] - The modified ''subject''. * [[PTPScript:Types:String|String]] - If ''subject'' is a String or Number. * [[PTPScript:Types:Array|Array]] - If ''subject'' is an Array. Returns ''subject'' with all occurrences of ''search'' replaced with the corresponding ''replace'' value. To count how many matches there are before replacement, ''[[search|search()]]'' can be used.