WordCount (String function): Difference between revisions
Jump to navigation
Jump to search
m (→Usage notes) |
mNo edit summary |
||
Line 1: | Line 1: | ||
{{Template:String:WordCount subtitle}} | {{Template:String:WordCount subtitle}} | ||
< | <var>WordCount</var> returns the number of words in its method object string. | ||
Note that processing a string of words may be better accomplished with the <var>[[StringTokenizer class|StringTokenizer]]</var> class. | Note that processing a string of words may be better accomplished with the <var>[[StringTokenizer class|StringTokenizer]]</var> class. | ||
Line 8: | Line 9: | ||
===Syntax terms=== | ===Syntax terms=== | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>%number</th><td> | <tr><th>%number</th><td>A numeric variable to contain the number of words in the <var class="term">string</var> method object. | ||
</td></tr> | </td></tr> | ||
<tr><th>string</th> | <tr><th>string</th> | ||
<td>The list of words to be counted. | <td>The string that is the list of words to be counted. | ||
</td></tr> | </td></tr> | ||
<tr><th><var>Spaces</var></th> | <tr><th><var>Spaces</var></th> |
Revision as of 18:35, 21 March 2012
Count words in list (String class)
[Introduced in Sirius Mods 7.9]
WordCount returns the number of words in its method object string.
Note that processing a string of words may be better accomplished with the StringTokenizer class.
Syntax
%number = string:WordCount[( [Spaces= string])]
Syntax terms
%number | A numeric variable to contain the number of words in the string method object. |
---|---|
string | The string that is the list of words to be counted. |
Spaces | A set of "whitespace" characters, that is, characters that separate words. The default is the blank character. If the null string is provided, the blank character is used as the whitespace character. |
Usage notes
- WordCount is the OO version of $Lstr_Words.
Examples
The following fragment:
PrintText {~="I'd like to buy the world a joke":WordCount}
produces the following result:
"I'd like to buy the world a joke":WordCount=8
See also
- List of StringTokenizer methods
- Words, which produces a word sublist from a list of words
- Word, which selects a word from a list of words
- WordNumberIn and WordNumberOf, which returns the word number of a "needle" word within a "haystack" list of words