我需要创建一个对应于https://www.w3.org/2005/xpath-functions/collat ion/html-ascii-case-insensitive/ 的整理器,即在进行比较时它会忽略 ASCIIA-Z
和字符的大小写敏感性。a-z
我尝试使用以下 ICU4j 进行此操作RuleBasedCollator
:
final RuleBasedCollator collator =
new RuleBasedCollator("&a=A, b=B, c=C, d=D, e=E, f=F, g=G, h=H, "
+ "i=I, j=J, k=K, l=L, m=M, n=N, o=O, p=P, q=Q, r=R, s=S, t=T, "
+ "u=U, v=V, u=U, v=V, w=W, x=X, y=Y, z=Z").freeze();
但是,以下比较似乎失败了,我希望它会成功(即 return true
):
final SearchIterator searchIterator = new StringSearch(
"pu", new StringCharacterIterator("iNPut"), collator);
return searchIterator.first() >= 0;
我的规则中缺少什么?