UnicodeBefore (Unicode function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
No edit summary
m (misc cleanup)
Line 5: Line 5:
==Syntax==
==Syntax==
{{Template:Unicode:UnicodeAfter syntax}}
{{Template:Unicode:UnicodeAfter syntax}}
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table>
<tr><th>%outString</th>
<tr><th>%outUnicode</th>
<td>A unicode variable to hold the output of the parsed input unicode string.</td></tr>
<td>A <var>Unicode</var> variable to hold the output of the parsed input string, <var class="term">unicode</var>.</td></tr>
<tr><th>string</th>
 
<td>A unicode string that holds the string to be parsed.</td></tr>
<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 unicode string that holds the separator character or characters on which parsing occurs.</td></tr>
<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>number: The starting point for parsing. The default value is 1, indicating the beginning of the string.  This is a name-optional argument and cannot be 0. If a value larger than the string is specified, the method always returns a null string.</td></tr>
<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 %outString is the content of the string beginning at the start point and before first occurrence of the delimiter string encountered after the specified start point, or ending at the end of the string if the delimiter token is not encountered.
<ul>
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', the method looks for occurrences of those two lower-case letters and returns a value before said occurrence,
<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 left and right square brackets are created using the <var>[[U (String function)|U]]</var> method and placed in variables <code>%sqL</code> and <code>%sqR</code>. Depending on your browser's [[Unicode#Code points.2C character set mappings|codepage]], the square brackets may or may not render correctly. The variables are inserted into a <var>Unicode</var> string and used to parse that string:
The following request the left and right square brackets are created using the unicode method and placed in variables %sqL and %sqR. Depending on your browser's codepage, the square brackets may or may not render correctly. They are then inserted into a unicode string and used to parse that string:
<p class="code">begin    
<p><code>Released in 1966, Manos: The Hands of Fate </code></p>
%sqL           is string len 1 initial("&#x5B;":u) static
<p class="code">begin                                                                          
%sqR           is string len 1 initial("&#x5D;":u) static
%sqL                 is string len 1 initial("&#x5B;":u) static                
%x is unicode
%sqR                 is string len 1 initial("&#x5D;":u) static                
%x = 'Released in 1966, Manos: The Hands of Fate ' with %sqL with -
%x is unicode                                                                  
     ' is a D-minus ' with %sqR with -  
%x = 'Released in 1966, Manos: The Hands of Fate ' with %sql with -            
     ' is a D-minus ' with %sqr with -                                          
     ' of a B movie: Its plot, about desert-dwelling pagans, makes little sense.'
     ' of a B movie: Its plot, about desert-dwelling pagans, makes little sense.'
printText {%x:unicodeBefore(%sqL)}                                              
printText {%x:unicodeBefore(%sqL)}
end                                                                            
end
</p>
</p>
<p>
The request result is:</p>
<p class="output">Released in 1966, Manos: The Hands of Fate </p>


==See also==
==See also==
{{Template:Unicode:UnicodeBefore footer}}
{{Template:Unicode:UnicodeBefore footer}}
The <var>[[UnicodeAfter (Unicode function)|UnicodeAfter]]</var> string method.

Revision as of 01:18, 7 May 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 left and right square brackets are created using the U method and placed in variables %sqL and %sqR. Depending on your browser's codepage, the square brackets may or may not render correctly. The variables are inserted into a Unicode string and used to parse that string:

begin %sqL is string len 1 initial("[":u) static %sqR is string len 1 initial("]":u) static %x is unicode %x = 'Released in 1966, Manos: The Hands of Fate ' with %sqL with - ' is a D-minus ' with %sqR with - ' of a B movie: Its plot, about desert-dwelling pagans, makes little sense.' printText {%x:unicodeBefore(%sqL)} end

The request result is:

Released in 1966, Manos: The Hands of Fate

See also