StartOfString (StringTokenizer function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (1 revision)
Line 10: Line 10:
<td>A string variable to receive the characters that precede the current position. </td></tr>
<td>A string variable to receive the characters that precede the current position. </td></tr>
<tr><th>%tok</th>
<tr><th>%tok</th>
<td>A StringTokenizer object variable.</td></tr>
<td>A <var>StringTokenizer</var> object variable.</td></tr>
</table>
</table>
==Usage notes==
==Usage notes==
<ul>
<ul>
<li>StartOfString does not advance the position.
<li><var>StartOfString</var> does not advance the position.
<li>The substring returned by StartOfString ends at (but does not include)
<li>The substring returned by <var>StartOfString</var> ends at (but does not include)
the first character of the current token,
the first character of the current token,
the position of which is the value of [[CurrentTokenPosition (StringTokenizer property)|CurrentTokenPosition]].
the position of which is the value of [[CurrentTokenPosition (StringTokenizer property)|CurrentTokenPosition]].
The value of the current token is returned by [[CurrentToken (StringTokenizer function)|CurrentToken]].
The value of the current token is returned by [[CurrentToken (StringTokenizer function)|CurrentToken]].
<li>StartOfString returns a null string if it is issued before a token is
<li><var>StartOfString</var> returns a null string if it is issued before a token is
found or if the value of [[NextPosition (StringTokenizer property)|NextPosition]] is <tt>1</tt>.
found or if the value of [[NextPosition (StringTokenizer property)|NextPosition]] is <tt>1</tt>.
<li>The [[RestOfString (StringTokenizer function)|RestOfString]] function
<li>The [[RestOfString (StringTokenizer function)|RestOfString]] function
Line 27: Line 27:
==Examples==
==Examples==


The following request fragment shows that consecutive StartOfString statements
The following request fragment shows that consecutive <var>StartOfString</var> statements
do not advance the position:
do not advance the position:
<pre>
<pre>
     %tok:string = 'A StartOfString example'
     %tok:string = 'A <var>StartOfString</var> example'
     %tok:findToken:('example')
     %tok:findToken:('example')
     printText {%tok:startOfString}
     printText {%tok:startOfString}
Line 38: Line 38:
The result is:
The result is:
<pre>
<pre>
     A StartOfString
     A <var>StartOfString</var>
     A StartOfString \\
     A <var>StartOfString</var> \\
</pre>
</pre>
==See also==
==See also==
{{Template:StringTokenizer:StartOfString footer}}
{{Template:StringTokenizer:StartOfString footer}}

Revision as of 21:47, 6 February 2011

Substring that precedes first character of current token (StringTokenizer class)


This method returns the substring of the tokenizer string that precedes the first character of the current token.

Syntax

%string = stringTokenizer:StartOfString

Syntax terms

%string A string variable to receive the characters that precede the current position.
%tok A StringTokenizer object variable.

Usage notes

  • StartOfString does not advance the position.
  • The substring returned by StartOfString ends at (but does not include) the first character of the current token, the position of which is the value of CurrentTokenPosition. The value of the current token is returned by CurrentToken.
  • StartOfString returns a null string if it is issued before a token is found or if the value of NextPosition is 1.
  • The RestOfString function returns the substring of the tokenizer string that follows the present tokenizing position.

Examples

The following request fragment shows that consecutive StartOfString statements do not advance the position:

    %tok:string = 'A <var>StartOfString</var> example'
    %tok:findToken:('example')
    printText {%tok:startOfString}
    printText {%tok:startOfString}\\

The result is:

    A <var>StartOfString</var>
    A <var>StartOfString</var> \\

See also