[String->Replace] modifies the string by replacing the specified find string with the replacement string. This method takes two forms.
The first form requires two parameters. The first parameter specifies the substring that should be replaced. The second parameter specifies the replacement string. By default case is not used when determining what substring to replace. An optional -Case parameter takes case sensitivity into account when making the replacement.
The second form requires one parameter. The first parameter specifies a regular expression that matches a substring to be replaced. An optional second parameter specifies the replacement string. If the second parameter is omitted, then all instances of the matched substring are removed. An optional third boolean parameter -Ignorecase specifies whether to ignore case sensitivity.
Every instance of the substring will be replaced. For more control use the [String_Replace] method or the [String_ReplaceRegExp] method.
'String Object'->replace('String Pattern','Replacement Pattern')
'String Object'->replace('String Pattern','Replacement Pattern', -case)
'String Object'->replace('Regular Expression','Replacement Pattern')
'String Object'->replace('Regular Expression','Replacement Pattern',Boolean)
Use the [string->replace] method. The following example modifies the string object in-place, replacing the word "quick" with "rare", then outputs the result.
Code
local('s') = 'The quick white rhino'
#s->replace('quick','rare')
#s
Result
The rare white rhino
Use the [string->replace] method. The following example modifies the string object in-place, replacing all vowels with an underscore character, then outputs the result.
Code
local('s') = 'The quick white rhino'
#s->replace(regexp('[aieou]'),'_')
#s
Result
Th_ q__ck wh_t_ rh_n_
Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft
Recent Comments