After (String function): Difference between revisions
mNo edit summary |
mNo edit summary |
||
Line 5: | Line 5: | ||
==Syntax== | ==Syntax== | ||
{{Template:String:After syntax}} | {{Template:String:After syntax}} | ||
===Syntax terms=== | ===Syntax terms=== | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>%outString</th> | <tr><th>%outString</th> | ||
<td>A | <td>A <var>String</var> or <var>Longstring</var> variable. If a string is specified, it must be long enough to hold the resulting parsed string. If the defined string is shorter than needed to hold the result, a request canceling error occurs.</td></tr> | ||
<tr><th>string</th> | <tr><th>string</th> | ||
<td>A | <td>A <var>String</var> or <var>Longstring</var> variable that holds the string to be parsed.</td></tr> | ||
<tr><th>substring</th> | <tr><th>substring</th> | ||
<td>A | <td>A <var>String</var> or <var>Longstring</var> variable that holds the separator character or characters on which parsing occurs.</td></tr> | ||
<tr><th><var>Start</var></th> | <tr><th><var>Start</var></th> | ||
<td>number | <td>A number that is the starting point for parsing. The default value is 1, indicating the beginning of the string. This is a [[Notation_conventions_for_methods#Named_arguments|name allowed]] argument, and it cannot be 0. If you specify a value larger than the string, <var>After</var> returns a null string.</td></tr> | ||
</table> | </table> | ||
==Usage notes== | ==Usage notes== | ||
If a starting value is | <ul> | ||
The delimiter string is not a list of individual delimiters, but a single delimiter which may be multiple characters. | <li>If a starting value is specified, <var class="term">%outString</var> is the string content that begins after the first occurrence of the delimiter string encountered after the specified start value, and that ends at the end of the string. | ||
This method is always case-sensitive. | The delimiter string is not a list of individual delimiters, but a single delimiter which may be multiple characters. In other words, if your delimiter is <code>ok</code>, <var>After</var> looks for occurrences of those two lowercase letters and returns a value after the first such occurrence that follows the start value. </li> | ||
<li>This method is always case-sensitive. </li> | |||
</ul> | |||
==Examples== | ==Examples== | ||
The following string (note the initial blanks) is the result of the request displayed below it: | |||
The | |||
<p><code> I am the Walrus! Koo Koo Kachoo!</code></p> | <p><code> I am the Walrus! Koo Koo Kachoo!</code></p> | ||
<p class="code">begin | <p class="code">begin | ||
Line 30: | Line 38: | ||
</p> | </p> | ||
The following request | The following string is the result of the request displayed below it: | ||
<p><code> Koo Koo Kachoo!</code></p> | <p><code> Koo Koo Kachoo!</code></p> | ||
<p class="code">begin | <p class="code">begin | ||
Line 38: | Line 46: | ||
</p> | </p> | ||
The following prints each blank-delimited word, one at a time | The following request prints each blank-delimited word, one at a time: | ||
<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 49: | Line 57: | ||
==See also== | ==See also== | ||
<ul> | |||
<li><var>[[Before (String function)|Before]]</var></li> | |||
</ul> | |||
{{Template:String:Before footer}} | {{Template:String:Before footer}} | ||
Revision as of 16:25, 6 June 2014
Part of string after a substring (String class)
[Introduced in Model 204 7.5]
After operates on a string and returns the portion of that string after a user-specified delimiter. To get the portion of the string before a delimiter, use the Before string method.
Syntax
%outString = string:After( substring, [Start= number])
Syntax terms
%outString | A String or Longstring variable. If a string is specified, it must be long enough to hold the resulting parsed string. If the defined string is shorter than needed to hold the result, a request canceling error occurs. |
---|---|
string | A String or Longstring variable that holds the string to be parsed. |
substring | A String or Longstring variable that holds the separator character or characters on which parsing occurs. |
Start | A number that is the starting point for parsing. The default value is 1, indicating the beginning of the string. This is a name allowed argument, and it cannot be 0. If you specify a value larger than the string, After returns a null string. |
Usage notes
- If a starting value is specified, %outString is the string content that begins after the first occurrence of the delimiter string encountered after the specified start value, and that ends at the end of the string.
The delimiter string is not a list of individual delimiters, but a single delimiter which may be multiple characters. In other words, if your delimiter is
ok
, After looks for occurrences of those two lowercase letters and returns a value after the first such occurrence that follows the start value. - This method is always case-sensitive.
Examples
The following string (note the initial blanks) is the result of the request displayed below it:
I am the Walrus! Koo Koo Kachoo!
begin %x is string len 64 initial('I am the Eggman! I am the Walrus! Koo Koo Kachoo!') printText {%x:after('!')} end
The following string is the result of the request displayed below it:
Koo Koo Kachoo!
begin %x is string len 64 initial('I am the Eggman! I am the Walrus! Koo Koo Kachoo!') printText {%x:after('!',start=20)} end
The following request prints each blank-delimited word, one at a time:
begin %x is string len 64 initial('I am the Eggman! I am the Walrus! Koo Koo Kachoo!') repeat while %x:length print %x:before(' ') %x = %x:after(' ') end repeat end