Remove (String function): Difference between revisions
Jump to navigation
Jump to search
m (Apply Dave's comments) |
m (printtext) |
||
Line 20: | Line 20: | ||
<ul><li>The search for the target <var class="term">substring</var> is context sensitive; case <b><i>matters</i></b> in the attempt to find and remove the target characters. | <ul><li>The search for the target <var class="term">substring</var> is context sensitive; case <b><i>matters</i></b> in the attempt to find and remove the target characters. | ||
<li><var>Remove</var> is equivalent to calling <var>[[Replace (String function)|Replace]]</var> method with an empty replacement string argument. | <li><var>Remove</var> is equivalent to calling <var>[[Replace (String function)|Replace]]</var> method with an empty replacement string argument. | ||
<li><var>Remove</var> is available as of <var class="product">[[Sirius Mods]]</var> Version 7.3.</ul> | <li><var>Remove</var> is available as of <var class="product">[[Sirius Mods|"Sirius Mods"]]</var> Version 7.3.</ul> | ||
==Examples== | ==Examples== | ||
Line 34: | Line 34: | ||
%substr = ' me' | %substr = ' me' | ||
%out = %x:remove(%substr) | %out = %x:remove(%substr) | ||
printText {~} is {%out} | [[PrintText statement|printText]] {~} is {%out} | ||
%substr = 'e' | %substr = 'e' | ||
Line 47: | Line 47: | ||
==See also== | ==See also== | ||
{{Template:String:Remove footer}} | {{Template:String:Remove footer}} |
Revision as of 08:51, 23 February 2011
Remove the occurrences of a specified substring (String class)
The Remove intrinsic function removes one or multiple occurrences of a specified substring from the method object (input) string, returning the modified version.
Syntax
%outString = string:Remove( substring, [Count= number])
Syntax terms
%outString | A string variable to receive the modified method object (input) string. |
---|---|
string | The method object (ie: input) string to which the method is applied. |
substring | The substring that the method attempts to remove in the method object string. If string contains no occurrences of substring, %outString is set to a copy of string. If substring is null or longer than 256 characters, the request is cancelled. |
Count | An optional, name-required, argument that is the number of occurrences of substring to remove. Only values greater than 0 are valid. If number is:
|
Usage notes
- The search for the target substring is context sensitive; case matters in the attempt to find and remove the target characters.
- Remove is equivalent to calling Replace method with an empty replacement string argument.
- Remove is available as of "Sirius Mods" Version 7.3.
Examples
-
The following request shows two examples of Remove calls against the same input string: the first call removes an occurrence of a specified substring; the second removes both occurrences of a different substring.
begin %x is longstring %substr is string len 6 %repl is string len 2 %out is longstring %x = 'Remove me' %substr = ' me' %out = %x:remove(%substr) printText {~} is {%out} %substr = 'e' %out = %x:remove(%substr, Count=2) printText {~} is {%out} end
The request output follows:
%out is Remove %out is Rmov me