replace - string replace
The replace function substitutes a part of a string with another.
The replace function is greedy and processes all occurances of the text to be replaced (A regular expression with the Global flag is used).
The function behaves like the php function str_replace($find, $replace, $subject)
Usage(s)
replace ( $search , $replace , $subject ) |
Returns the $subject string with all occurances of $search replaced by the string $replace |
Parameter(s)
$search |
The string to be replaced. (currently there are some issues with regex reserver characters) |
$replace |
The target string that will be substituting all $search strings |
$subject |
The target string to process and replace values in |
Example(s)
Replacing simple strings
replace(search,replace,I find it easy to search.)
Returns: I find it easy to replace.
|
Changing the formatting of a data type
replace(:,-,mac()) - Will return a mac address with a dash as separator instead of a colon :
d7:77:ea:9d:fc:7d --> d7-77-ea-9d-fc-7d
78:f7:20:36:79:1b --> 78-f7-20-36-79-1b
c6:f5:1e:46:db:ff --> c6-f5-1e-46-db-ff
|
Removing specific characters
replace(-,,itin()) - This will remove all the dashes from the Tax PayerNumber
936-76-6729 --> 936766729
|
See also
truncate - truncate string length
reverse - reverse a string
leftpad - Left Padding
rightpad - Right Padding