Yahoo! UI Library

unicode  3.3.0pr1

Yahoo! UI Library > unicode > Unicode.WordBreak
Search:
 
Filters

static Class Unicode.WordBreak

Provides utility methods for splitting strings on word breaks and determining whether a character represents a word boundary, using the algorithm defined in the Unicode Text Segmentation guidelines (Unicode Standard Annex #29).

Methods

_classify

protected static Array _classify ( string )
Returns a character classification map for the specified 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 after the specified character index, false otherwise.
Parameters:
map <Array> Character classification map generated by _classify.
index <Number> Character index to test.

getUniqueWords

static Array getUniqueWords ( string , options )
Returns an array containing only unique words from the specified string. For example, the string 'foo bar baz foo' would result in the array ['foo', 'bar', 'baz'].
Parameters:
string <String> String to split.
options <Object> (optional) Options (see getWords() for details).
Returns: Array
Array of unique words.

getWords

static Array getWords ( string , options )
Splits the specified string into an array of individual words.
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 is false.
includePunctuation (Boolean)
If true, the returned array will include punctuation characters. Default is false.
includeWhitespace (Boolean)
If true, the returned array will include whitespace characters. Default is false.
Returns: Array
Array of words.

isWordBoundary

static Boolean isWordBoundary ( string , index )
Returns true if there is a word boundary after the specified character index in the given string, false otherwise.
Parameters:
string <String> String to test.
index <Number> Character index to test within the string.
Returns: Boolean
true for a word boundary, false otherwise.


Copyright © 2010 Yahoo! Inc. All rights reserved.