I answered this on the Rangy forum. In case that link stops working, here's what I wrote:
It's set up for Latin script by default, but you can specify a regular expression in the expand()
method. The default is /[a-z0-9]+('[a-z0-9]+)*/gi
, which is pretty basic but provided as a reasonable default for English.
A simple example:
sel.expand("word", {
wordOptions: {
wordRegex: /[a-z0-9\u0400-\u04FF]+('[a-z0-9\u0400-\u04FF]+)*/gi
}
});
I'm no expert in Cyrillic so I've just added some Cyrillic characters to the character classes in the regular expression for illustration purposes. You could do better using XRegExp and its Unicode plugin:
sel.expand("word", {
wordOptions: {
wordRegex: XRegExp("[\\p{L}\\d]+('[\\p{L}\\d]+)*", "gi")
}
});