indexOf区分大小写? [英] indexOf Case Sensitive?

查看:181
本文介绍了indexOf区分大小写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

indexOf(String)方法是否区分大小写?如果有,是否有不区分大小写的版本?

Is the indexOf(String) method case sensitive? If so, is there a case insensitive version of it?

推荐答案

indexOf()方法都是区分大小写的。你可以通过事先将你的字符串转换为大写/小写来制作它们(粗略地,以一种破碎的方式,但是在很多情况下工作)不区分大小写:

The indexOf() methods are all case-sensitive. You can make them (roughly, in a broken way, but working for plenty of cases) case-insensitive by converting your strings to upper/lower case beforehand:

s1 = s1.toLowerCase(Locale.US);
s2 = s2.toLowerCase(Locale.US);
s1.indexOf(s2);

这篇关于indexOf区分大小写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆