_classify
protected
static
Array
_classify
(
string
)
- Parameters:
-
string <String>
String to classify.
- Returns:
Array
- Classification map.
_isWordBoundary
protected
static
Boolean
_isWordBoundary
(
map
,
index
)
Returns true
if there is a word boundary between the
specified character index and the next character index (or the end of the
string).
Note that there are always word breaks at the beginning and end of a
string, so _isWordBoundary('', 0)
and
_isWordBoundary('a', 0)
will both return true
.
- Parameters:
-
map <Array>
Character classification map generated by_classify
. -
index <Number>
Character index to test.
getUniqueWords
static
Array
getUniqueWords
(
string
,
options
)
'foo bar baz foo'
would result in
the array ['foo', 'bar', 'baz']
.
- Parameters:
-
string <String>
String to split. -
options <Object>
(optional) Options (seegetWords()
for details).
- Returns:
Array
- Array of unique words.
getWords
static
Array
getWords
(
string
,
options
)
- Parameters:
-
string <String>
String to split. -
options <Object>
(optional) Options object containing zero or more of the following properties:- ignoreCase (Boolean)
-
If
true
, the string will be converted to lowercase before being split. Default isfalse
. - includePunctuation (Boolean)
-
If
true
, the returned array will include punctuation characters. Default isfalse
. - includeWhitespace (Boolean)
-
If
true
, the returned array will include whitespace characters. Default isfalse
.
- Returns:
Array
- Array of words.
isWordBoundary
static
Boolean
isWordBoundary
(
string
,
index
)
Returns true
if there is a word boundary between the
specified character index and the next character index (or the end of the
string).
Note that there are always word breaks at the beginning and end of a
string, so isWordBoundary('', 0)
and
isWordBoundary('a', 0)
will both return true
.
- Parameters:
-
string <String>
String to test. -
index <Number>
Character index to test within the string.
- Returns:
Boolean
true
for a word boundary,false
otherwise.