UnicodeBefore (Unicode function): Difference between revisions
No edit summary |
m (remove second example) |
||
(5 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
==Syntax== | ==Syntax== | ||
{{Template:Unicode:UnicodeAfter syntax}} | {{Template:Unicode:UnicodeAfter syntax}} | ||
===Syntax terms=== | ===Syntax terms=== | ||
<table | <table> | ||
<tr><th>% | <tr><th>%outUnicode</th> | ||
<td>A | <td>A <var>Unicode</var> variable to hold the output of the parsed input string, <var class="term">unicode</var>.</td></tr> | ||
<tr><th> | |||
<td>A | <tr><th>unicode</th> | ||
<td>A <var>Unicode</var> string that holds the string to be parsed.</td></tr> | |||
<tr><th>substring</th> | <tr><th>substring</th> | ||
<td>A | <td>A <var>Unicode</var> string 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> | <td>This numeric value is the starting point for parsing. The default value is 1, indicating the beginning of the string. | ||
<p> | |||
This is a [[Notation conventions for methods#Named arguments|name required]] argument, and it cannot be 0. If a value larger than the string length is specified, the method returns a null string. </p></td></tr> | |||
</table> | </table> | ||
==Usage notes== | ==Usage notes== | ||
If a starting value is entered, the % | <ul> | ||
The delimiter string is not a list of individual delimiters | <li>If a starting value is entered, the <var class="term">%outUnicode</var> value is the content of the string that begins before the first occurrence of the delimiter substring encountered after the specified start point, or that ends at the end of the string if the delimiter token is not encountered. | ||
This method is always case-sensitive. | <p> | ||
The delimiter string is not a list of individual delimiters; it is a single delimiter which may be multiple characters. If your delimiter is "ok", the method looks for occurrences of those two lowercase letters, and it returns a value that starts before the first occurrence found after the starting point. </p></li> | |||
<li>This method is always case-sensitive. </li> | |||
</ul> | |||
==Examples== | ==Examples== | ||
In the following request, the given initial string is "Manos: The Hands of Fate [is a D-minus] of a B movie". The substring that precedes the right square bracket (<tt>]</tt>) character representation is excerpted by <var>UnicodeBefore</var>. The request uses an [[Release notes for Model 204 version 7.6#New XHTML entities for square-bracket characters|enhancement for square-bracket handling]] introduced in version 7.6 of Model 204. | |||
<p class="code">begin | |||
%x is unicode | |||
<p class="code">begin | %x = 'Manos: The Hands of Fate <b>[</b>is a D-minus<b>]</b> '<b>:U</b> 'of a B movie' | ||
printText {%x:unicodeBefore(']'<b>:U</b>)} | |||
end | |||
%x is unicode | |||
%x = ' | |||
printText {%x:unicodeBefore( | |||
end | |||
</p> | </p> | ||
<p> | |||
The result is:</p> | |||
<p class="output">Manos: The Hands of Fate [is a D-minus</p> | |||
==See also== | ==See also== | ||
{{Template:Unicode:UnicodeBefore footer}} | {{Template:Unicode:UnicodeBefore footer}} | ||
Latest revision as of 17:34, 3 June 2016
Part of string before a substring (Unicode class)
[Introduced in Model 204 7.5]
UnicodeBefore operates on a Unicode variable or string and returns the portion of that string before a user-specified delimiter. To get the portion of the string after a delimiter, use the UnicodeAfter string method.
Syntax
%outUnicode = unicode:UnicodeAfter( substring, [Start= number])
Syntax terms
%outUnicode | A Unicode variable to hold the output of the parsed input string, unicode. |
---|---|
unicode | A Unicode string that holds the string to be parsed. |
substring | A Unicode string that holds the separator character or characters on which parsing occurs. |
Start | This numeric value is the starting point for parsing. The default value is 1, indicating the beginning of the string.
This is a name required argument, and it cannot be 0. If a value larger than the string length is specified, the method returns a null string. |
Usage notes
- If a starting value is entered, the %outUnicode value is the content of the string that begins before the first occurrence of the delimiter substring encountered after the specified start point, or that ends at the end of the string if the delimiter token is not encountered.
The delimiter string is not a list of individual delimiters; it is a single delimiter which may be multiple characters. If your delimiter is "ok", the method looks for occurrences of those two lowercase letters, and it returns a value that starts before the first occurrence found after the starting point.
- This method is always case-sensitive.
Examples
In the following request, the given initial string is "Manos: The Hands of Fate [is a D-minus] of a B movie". The substring that precedes the right square bracket (]) character representation is excerpted by UnicodeBefore. The request uses an enhancement for square-bracket handling introduced in version 7.6 of Model 204.
begin %x is unicode %x = 'Manos: The Hands of Fate [is a D-minus] ':U 'of a B movie' printText {%x:unicodeBefore(']':U)} end
The result is:
Manos: The Hands of Fate [is a D-minus