Before (String function): Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{{Template:String:Before subtitle}} | {{Template:String:Before subtitle}} | ||
<var>Before</var> operates on a string and returns the portion of that string prior to the user-specified delimiter. To get the portion of the string after a delimiter, use the <var>[[After (String function)| | <var>Before</var> operates on a string and returns the portion of that string prior to the user-specified delimiter. To get the portion of the string after a delimiter, use the <var>[[After (String function)|After]]</var> string method. | ||
==Syntax== | ==Syntax== | ||
{{Template:String:Before syntax}} | {{Template:String:Before syntax}} | ||
Line 19: | Line 19: | ||
The following request prints | The following request prints | ||
<p><code>I am the Eggman</p> | <p><code>I am the Eggman</code></p> | ||
<p class="code">begin | <p class="code">begin | ||
%x is string len 64 initial('I am the Eggman! I am the Walrus! Koo Koo Kachoo!') | %x is string len 64 initial('I am the Eggman! I am the Walrus! Koo Koo Kachoo!') | ||
Line 27: | Line 27: | ||
The following request prints | The following request prints | ||
<p><code>Eggman!</p> | <p><code>Eggman!</code></p> | ||
<p class="code">begin | <p class="code">begin | ||
%x is string len 64 initial('I am the Eggman! I am the Walrus! Koo Koo Kachoo!') | %x is string len 64 initial('I am the Eggman! I am the Walrus! Koo Koo Kachoo!') | ||
printText {%x:before('!',10)} | printText {%x:before('!',start=10)} | ||
end | end | ||
</p> | </p> |
Revision as of 19:33, 23 April 2014
Part of string before a substring (String class)
[Introduced in Model 204 7.5]
Before operates on a string and returns the portion of that string prior to the user-specified delimiter. To get the portion of the string after a delimiter, use the After string method.
Syntax
%outString = string:Before( substring, [Start= number])
Syntax terms
%outString | string |
---|---|
string | string |
substring | string |
Start | number This default value of this argument is ??. |
Usage notes
Examples
The following request prints
I am the Eggman
begin %x is string len 64 initial('I am the Eggman! I am the Walrus! Koo Koo Kachoo!') printText {%x:before('!')} end
The following request prints
Eggman!
begin %x is string len 64 initial('I am the Eggman! I am the Walrus! Koo Koo Kachoo!') printText {%x:before('!',start=10)} end
See also
The Before string method.