int pluralRuleStart = ruleText.indexOf("$(");
int pluralRuleEnd = (pluralRuleStart >= 0 ? ruleText.indexOf(')', pluralRuleStart) : -1);
if (pluralRuleEnd >= 0) {
- int endType = ruleText.indexOf(',');
+ int endType = ruleText.indexOf(',', pluralRuleStart);
if (endType < 0) {
throw new IllegalArgumentException("Rule \"" + ruleText + "\" does not have a defined type");
}
else {
currMatchIndex = source.indexOf(currArg);
}
- if (currMatchIndex > matchedIndex && (matchedWord == null || currArg.length() > matchedWord.length())) {
+ if (currMatchIndex >= 0 && currMatchIndex >= matchedIndex && (matchedWord == null || currArg.length() > matchedWord.length())) {
matchedIndex = currMatchIndex;
matchedWord = currArg;
keyword = pattern.substring(partStart.getLimit(), partLimit.getIndex());
* <td width="37">$(cardinal,<i>plural syntax</i>)</td>
* <td width="23"></td>
* <td width="165" valign="top">in all rule sets</td>
- * <td>This provides the ability to choose a word based on the number divided by the base value for the specified locale.
- * This uses the cardinal plural rules from PluralFormat. All strings used in the plural format are treated as the same base value for parsing.</td>
+ * <td>This provides the ability to choose a word based on the number divided by the radix to the power of the
+ * exponent of the base value for the specified locale, which is normally equivalent to the << value.
+ * This uses the cardinal plural rules from PluralFormat. All strings used in the plural format are treated
+ * as the same base value for parsing.</td>
* </tr>
* <tr>
* <td width="37">$(ordinal,<i>plural syntax</i>)</td>
* <td width="23"></td>
* <td width="165" valign="top">in all rule sets</td>
- * <td>This provides the ability to choose a word based on the number divided by the base value for the specified locale.
- * This uses the ordinal plural rules from PluralFormat. All strings used in the plural format are treated as the same base value for parsing.</td>
+ * <td>This provides the ability to choose a word based on the number divided by the radix to the power of the
+ * exponent of the base value for the specified locale, which is normally equivalent to the << value.
+ * This uses the ordinal plural rules from PluralFormat. All strings used in the plural format are treated
+ * as the same base value for parsing.</td>
* </tr>
* </table>
*