StringUpTo (StringTokenizer function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
Line 1: Line 1:
{{Template:StringTokenizer:StringUpTo subtitle}}
{{Template:StringTokenizer:StringUpTo subtitle}}


This method returns a substring of the tokenizing string, starting at the current position and ending just before the occurrence of its argument string. And it advances the tokenizer position past the next occurrence of its argument string.
This method returns a substring of the tokenizing string, starting at the current position and ending just before the occurrence of its argument string.  
 
==Syntax==
==Syntax==
{{Template:StringTokenizer:StringUpTo syntax}}
{{Template:StringTokenizer:StringUpTo syntax}}
Line 22: Line 21:
==Usage notes==
==Usage notes==
<ul>
<ul>
<li>If <var>StringUpTo</var> locates an occurrence of its argument string, it moves the tokenizing position to the end of the located argument string.
<li>If <var>StringUpTo</var> locates an occurrence of its argument string, it advances the tokenizing position to the end of that located argument string.
 
<li>Because a failure to match the target string returns the rest of the tokenizer string, <var>StringUpTo</var> leaves no easy way to determine if you get a result string because you got a match or because you went to the end of the string. A good technique then may be to follow a <var>StringUpTo</var> call with a <var>[[NextPosition (StringTokenizer function)|NextPosition]]</var> call to check your result.
<li>Because a failure to match the target string returns the rest of the tokenizer string, <var>StringUpTo</var> leaves no easy way to determine if you get a result string because you got a match or because you went to the end of the string. A good technique then may be to follow a <var>StringUpTo</var> call with a <var>[[NextPosition (StringTokenizer function)|NextPosition]]</var> call to check your result.
</ul>
</ul>

Revision as of 23:01, 3 July 2012

String from start to current position (StringTokenizer class)

[Introduced in Sirius Mods 7.8]


This method returns a substring of the tokenizing string, starting at the current position and ending just before the occurrence of its argument string.

Syntax

%string = stringTokenizer:StringUpTo( string)

Syntax terms

%string A string variable to contain the returned substring.
stringTokenizer A StringTokenizer object expression.
string The string within stringTokenizer up to which the tokenizer scans to determine the substring to return to %string.

If string is not found, StringUpTo returns the rest of the string being tokenized.

Usage notes

  • If StringUpTo locates an occurrence of its argument string, it advances the tokenizing position to the end of that located argument string.
  • Because a failure to match the target string returns the rest of the tokenizer string, StringUpTo leaves no easy way to determine if you get a result string because you got a match or because you went to the end of the string. A good technique then may be to follow a StringUpTo call with a NextPosition call to check your result.

Examples

See also