$SubCnt: Difference between revisions
m (1 revision) |
m (1 revision) |
||
Line 2: | Line 2: | ||
<span class="pageSubtitle">Count occurrences of one string in another</span> | <span class="pageSubtitle">Count occurrences of one string in another</span> | ||
<p class="warning">Most Sirius $functions have been deprecated in favor of Object Oriented methods. There is currently no OO equivalent for the $SubCnt function.</p> | <p class="warning">Most Sirius $functions have been deprecated in favor of Object Oriented methods. There is currently no OO equivalent for the <var>$SubCnt</var> function.</p> | ||
This function counts the occurrences of one string in another. | This function counts the occurrences of one string in another. | ||
The $SubCnt function accepts two arguments and returns a numeric result that is the count of occurrences of the second argument string in the first argument string. | The <var>$SubCnt</var> function accepts two arguments and returns a numeric result that is the count of occurrences of the second argument string in the first argument string. | ||
The first argument is an arbitrary string. | The first argument is an arbitrary string. |
Revision as of 01:18, 19 October 2012
Count occurrences of one string in another
Most Sirius $functions have been deprecated in favor of Object Oriented methods. There is currently no OO equivalent for the $SubCnt function.
This function counts the occurrences of one string in another.
The $SubCnt function accepts two arguments and returns a numeric result that is the count of occurrences of the second argument string in the first argument string.
The first argument is an arbitrary string.
The second argument is another arbitrary string.
Syntax
<section begin="syntax" /> %COUNT = $SubCnt(string, substring) <section end="syntax" />
For example
%JUNK = $SubCnt('ABCDABAB', 'AB')
would set %JUNK to 3 and
%JUNK = $SubCnt('WE HAVE WAITED LONG ENOUGH', - 'WEHAVE')
would set %JUNK to 0 and
%JUNK = $SubCnt('WE HAVE WAITED LONG ENOUGH', 'E')
would set %JUNK to 4.