throws Throwable
  public static Value str_word_count(String string,                                     @Optional int format,                                     @Optional String additionalWordCharacters)    throws Throwable  {    if (format < 0 || format > 2)      return NullValue.NULL;    int strlen = string.length();    boolean isAdditionalWordCharacters = additionalWordCharacters.length() > 0;    ArrayValueImpl resultArray = null;    if (format > 0)      resultArray = new ArrayValueImpl();    boolean isBetweenWords = true;    int wordCount = 0;    int lastWordStart = 0;    for (int i = 0; i <= strlen; i++) {      boolean isWordCharacter;      if (i < strlen) {        int ch = string.charAt(i);        isWordCharacter = Character.isLetter(ch)                          || ch == '-'                          || ch == '\''                          || (isAdditionalWordCharacters                              && additionalWordCharacters.indexOf(ch) > -1);      }      else        isWordCharacter = false;      if (isWordCharacter) {        if (isBetweenWords) {          // starting a word          isBetweenWords = false;          lastWordStart = i;          wordCount++;        }      }      else {        if (!isBetweenWords) {          // finished a word          isBetweenWords = true;          if (format > 0) {            StringValue word = new StringValueImpl(string.substring(lastWordStart, i));            if (format == 1)              resultArray.append(word);            else if (format == 2)              resultArray.put(new LongValue(lastWordStart), word);          }        }      }    }    return resultArray == null ? new LongValue(wordCount) : resultArray;  }