$Parse: Difference between revisions
m (1 revision) |
m (1 revision) |
||
Line 15: | Line 15: | ||
==Syntax== | ==Syntax== | ||
<p class="syntax"><section begin="syntax" /> %PIECE = $Parse(string, delims, start_pos) | <p class="syntax"><section begin="syntax" />%PIECE = $Parse(string, delims, start_pos) | ||
<section end="syntax" /></p> | <section end="syntax" /></p> | ||
<p class="caption">$Parse Function | <p class="caption">$Parse Function |
Revision as of 20:32, 24 October 2012
Part of string preceding character in delimiter set
Most Sirius $functions have been deprecated in favor of Object Oriented methods. There is no direct OO equivalent for the $Parse function, but you might find a more powerful solution in the StringTokenizer class or elements of the Sirius Regex implementation, such as the RegexSplit (String function).
This function returns part of a given string: the characters after a specified or implied starting position and until a character in a delimiter set.
The $Parse function accepts three arguments and returns a string result that is a part of the first input string.
The first argument is an arbitrary string.
The second argument is a string containing a set of delimiter characters.
The third argument is a starting position in the first argument string and has a default of 1.
Syntax
<section begin="syntax" />%PIECE = $Parse(string, delims, start_pos) <section end="syntax" />
Examples
The following statement would set %JUNK to WASTE NOT:
%JUNK = $Parse('WASTE NOT(WANT|NOT', '(|')
The statement below would set %JUNK to WASTE NOT(WANT:
%JUNK = $Parse('WASTE NOT(WANT|NOT', '|')
The following statement would set %JUNK to E NOT(WANT:
%JUNK = $Parse('WASTE NOT(WANT|NOT', '|', 5)
$Parse returns the entire first argument string if none of the delimiter characters are found. The matching function which retrieves the part of the string after the delimiter is $ParseX.