UnicodeAfter (Unicode function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (→‎Examples: remove with)
m (→‎Examples: multiple tweaks)
Line 33: Line 33:


==Examples==
==Examples==
In the following requests, the substring that follows the right square bracket (<tt>]</tt>) character representation is excerpted by <var>UnicodeAfter</var>. Two variations of the request are shown because of an enhancement for square-bracket handling introduced in version 7.6 of Model&nbsp;204.
In the following requests, the given initial string is "Manos: The Hands of Fate [is a D-minus] of a B movie". The substring that follows the right square bracket (<tt>]</tt>) character representation is excerpted by <var>UnicodeAfter</var>. Two variations of the request are shown because of an enhancement for square-bracket handling introduced in version 7.6 of Model&nbsp;204.
<ul>
<ul>
<li>For version 7.6 and higher:  
<li>For version 7.6 and higher:  
<p>
<p>
The left and right square brackets used in this example are created using the <code>&lsqb;</code> and <code>&rsqb;</code> XHTML entities, added by zap maintenance in version 7.6. These entities are recommended because, depending on your PC's [[Unicode#Code points.2C character set mappings|codepage]], the [[Unicode#sqbrackets|square bracket characters may or may not render correctly]]: </p>
The left and right square brackets used in this example are created using the [[U (String function)|U constant function]] with the <code>&lsqb;</code> and <code>&rsqb;</code> XHTML entities, added by zap maintenance in version 7.6. These entities are recommended because, depending on your PC's [[Unicode#Code points.2C character set mappings|codepage]], the [[Unicode#sqbrackets|square bracket characters may or may not render correctly]]: </p>
<p class="code">begin       
<p class="code">begin       
%x is unicode
%x is unicode
%x = 'Released in 1966, Manos: The Hands of Fate &lsqb;is a D-minus&rsqb; ' -
%x = 'Manos: The Hands of Fate <b>&lsqb;</b>is a D-minus<b>&rsqb;</b> '<b>:U</b> 'of a B movie'
    'of a B movie: Its plot, about desert-dwelling pagans, makes little sense.'
print '%x is: ' %x
printText {%x:unicodeAfter('&rsqb;')}
printText {%x:unicodeAfter('&rsqb;')}
end
end
</p>
</p>
<p>
<p>
The request result is:</p>
The first line of output shows the effect of the <var>U</var> method and XHTML entities. The second line shows the substring returned by <var>UnicodeAfter</var>:</p>
<p class="output"> of a B movie: Its plot, about desert-dwelling pagans, makes little sense.</p></li>
<p class="output">%x is: Manos: The Hands of Fate [is a D-minus] of a B movie
of a B movie</p></li>


<li>For version 7.5:
<li>For version 7.5:
<p>
<p>
The left and right square brackets below are created using the <var>[[U (String function)|U]]</var> method and placed in variables <code>%sqL</code> and <code>%sqR</code>. The variables are inserted into a <var>Unicode</var> string and used to parse that string: </p>
The left and right square brackets below are created using the <var>[[U (String function)|U]]</var> method and placed in variables <code>%lsq</code> and <code>%rsq</code>. The variables are inserted into a <var>Unicode</var> string and used to parse that string: </p>
<p class="code">begin
<p class="code">begin
%sqL      is string len 1 initial("&#x5B;":u) static
%sqL      is string len 1 initial("&amp;#x5B;":U) static
%sqR      is string len 1 initial("&#x5D;":u) static  
%sqR      is string len 1 initial("&amp;#x5D;":U) static  
%x is unicode
%x is unicode
%x = 'Released in 1966, Manos: The Hands of Fate ' with %sqL with -
print '%x is: ' %x   
     ' is a D-minus ' with %sqr with -
%x = 'Manos: The Hands of Fate ' with %lsq with -
    ' of a B movie: Its plot, about desert-dwelling pagans, makes little sense.'
     'is a D-minus' with %rsq with ' of a B movie'
printText {%x:unicodeAfter(%sqR)}
printText {%x:unicodeAfter(%rsq)}
end
end
</p>
</p>
<p>
<p>
Again, the request result is:</p>
Again, the request result is:</p>
<p class="output"> of a B movie: Its plot, about desert-dwelling pagans, makes little sense.</p></li>
<p class="output">%x is: Manos: The Hands of Fate [is a D-minus] of a B movie
of a B movie</p></li>
</ul>
</ul>


==See also==
==See also==
{{Template:Unicode:UnicodeAfter footer}}
{{Template:Unicode:UnicodeAfter footer}}

Revision as of 01:32, 1 June 2016

Part of string after a substring (Unicode class)

[Introduced in Model 204 7.5]


UnicodeAfter operates on a Unicode variable or 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 UnicodeBefore 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 after the first occurrence of the delimiter substring encountered after the specified start point, and that ends at the end of the string.

    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 after the first occurrence found after the starting point.

  • This method is always case-sensitive.

Examples

In the following requests, the given initial string is "Manos: The Hands of Fate [is a D-minus] of a B movie". The substring that follows the right square bracket (]) character representation is excerpted by UnicodeAfter. Two variations of the request are shown because of an enhancement for square-bracket handling introduced in version 7.6 of Model 204.

  • For version 7.6 and higher:

    The left and right square brackets used in this example are created using the U constant function with the [ and ] XHTML entities, added by zap maintenance in version 7.6. These entities are recommended because, depending on your PC's codepage, the square bracket characters may or may not render correctly:

    begin %x is unicode %x = 'Manos: The Hands of Fate [is a D-minus] ':U 'of a B movie' print '%x is: ' %x printText {%x:unicodeAfter(']')} end

    The first line of output shows the effect of the U method and XHTML entities. The second line shows the substring returned by UnicodeAfter:

    %x is: Manos: The Hands of Fate [is a D-minus] of a B movie of a B movie

  • For version 7.5:

    The left and right square brackets below are created using the U method and placed in variables %lsq and %rsq. The variables are inserted into a Unicode string and used to parse that string:

    begin %sqL is string len 1 initial("&#x5B;":U) static %sqR is string len 1 initial("&#x5D;":U) static %x is unicode print '%x is: ' %x %x = 'Manos: The Hands of Fate ' with %lsq with - 'is a D-minus' with %rsq with ' of a B movie' printText {%x:unicodeAfter(%rsq)} end

    Again, the request result is:

    %x is: Manos: The Hands of Fate [is a D-minus] of a B movie of a B movie

See also